fix: write reliability and error-handling fixes#7
Merged
Conversation
…istent token error, and idempotent get --export - Use .get(environment, []) instead of [environment] on the scope dict so write does not KeyError on a brand-new environment with zero existing variables. - Narrow except Exception to except gitlab.exceptions.GitlabError so programming errors (like the above KeyError) surface instead of being swallowed as "unexpected error". - Use click.ClickException in the get command for missing GITLAB_TOKEN, matching write/list/download (clean message, no traceback). - Track which scope files have been opened during get --export so each file is truncated on first write and appended thereafter, preventing duplicate lines on re-run.
… and scope filtering Covers the critical logic paths: - Regression test for write to fresh environment scope (Task 1 fix) - Masking heuristic (KEY/SECRET/TOKEN substring match) - Consistent click.ClickException on missing GITLAB_TOKEN for all commands - get --export idempotence (no duplicate lines on re-run) - Scope filtering (global * vars included, other-env vars excluded) - prepare_gitlab_host URL normalisation
- Remove .%s from datefmt in logging.basicConfig (%s is not a valid strftime directive and renders literally). - Remove trailing blank line in gitlab_server.py.
Without explicit config, the Python release type treats every conventional commit as release-worthy. The config marks docs, test, ci, refactor, and chore sections as hidden so they ride along in the changelog but do not trigger a version bump on their own.
uv sync --group dev failed in CI. Use uv run --group dev instead, which auto-syncs before running. Add ruff to dev dependency group so it resolves through the project.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements and bug fixes to the GitLab project variables management tool, along with enhanced documentation and expanded test coverage. The most significant changes include improved error handling, idempotent export behavior, and comprehensive tests for core functionality and edge cases.
Bug fixes and behavior improvements:
writecommand where updating variables in a previously unseen environment scope could fail by using.get()with a default empty list (src/populate_secrets_gitlab/app.py).GITLAB_TOKENby raising aclick.ClickExceptioninstead of a genericException, ensuring cleaner CLI exits without tracebacks (src/populate_secrets_gitlab/app.py).writecommand to specifically catchgitlab.exceptions.GitlabError, providing clearer log messages (src/populate_secrets_gitlab/app.py).get --exportcommand idempotent by ensuring environment files are not appended to multiple times during a single run, preventing duplicate lines (src/populate_secrets_gitlab/app.py).Documentation updates:
downloadcommand toREADME.mdfor better usability and clarity. [1] [2]Testing and development tooling:
tests/test_app.pycovering:get --exportprepare_gitlab_hostutility function intests/test_util.py.devdependency group withpytestinpyproject.tomlfor easier test setup.