Skip to content

Fix --job argument interpreted as --job-token #1957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

meteozond
Copy link

Description of the problem, including code/CLI snippet

--job argument interpreted as --job-token arugment and conflicts with --private-token

Executing:

gitlab \
  --private-token ${GITLAB_API_KEY} -o json \
  project-artifact download \
  --project-id mdm/entities \
  --job ${JOB} \
  --ref-name ${REF} \

Expected Behavior

Artifact downloaded

Actual Behavior

gitlab: error: argument --job-token: not allowed with argument --private-token

Specifications

  • python-gitlab version: 3.2.0
  • API version you are using (v3/v4): doesn't meter
  • Gitlab server version (or gitlab.com): doesn't meter

PS

Looks like it happens because of default argparse.ArgumentParsers allow_abbrev behaviour - both --job and --job-token starts with --job chars.

Could be fixed here with:

    parser = argparse.ArgumentParser(
        add_help=add_help, description="GitLab API Command Line Interface",
+       allow_abbrev=False
    )

@nejch
Copy link
Member

nejch commented Apr 1, 2022

Thanks for the PR @meteozond! could you amend your commit message and force push again? (see CI failure)

That is really odd behavior with allow_abbrev TBH 🤔

@nejch
Copy link
Member

nejch commented Apr 27, 2022

Hi @meteozond I'm happy to merge this, just needs a few steps on your end to get green CI:

pip install tox # if you don't have tox
tox -e black
git add gitlab/
git commit --amend -m "fix(cli): change default `allow_abbrev` value to avoid argument collision"
git push -f

Let me know if you need any more help.

@nejch
Copy link
Member

nejch commented May 9, 2022

Thanks @meteozond for the fix. Your commit will be included in #2013 to get this merged :)

@nejch nejch closed this May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants