Skip to content

Update and fix variable _create_attrs and _update_attrs#3379

Open
PhilipNelson5 wants to merge 2 commits intopython-gitlab:mainfrom
PhilipNelson5:fix-var-attrs
Open

Update and fix variable _create_attrs and _update_attrs#3379
PhilipNelson5 wants to merge 2 commits intopython-gitlab:mainfrom
PhilipNelson5:fix-var-attrs

Conversation

@PhilipNelson5
Copy link
Copy Markdown

Changes

  1. make value an optional attribute for variable updates

    When updating a CI/CD variable that has been marked "Masked and hidden", you likely do not have the value when updating. In this case, the value is None which the api rejects (400: {'value': ['is invalid']}).

  2. add masked_and_hidden the the list of optional attributes for creating variables

    When creating variables which you want to be hidden, you have to use the masked_and_hidden property.

    I don't think this was causing problems but for the sake completion and documentation I think it makes sense to include.

Documentation and testing

Please consider whether this PR needs documentation and tests. This is not required, but highly appreciated:

@PhilipNelson5
Copy link
Copy Markdown
Author

I tried running the suite of functional tests but was unable to. I got the docker containers up but they were so unstable that even adding gl = gitlab.Gitlab( ... retry_transient_errors=True) couldn't get passed the 500 errors.

I was able to run the variable tests against a live gitlab instance to demonstrate to myself the tests failed before my changes and passed after.

@PhilipNelson5 PhilipNelson5 force-pushed the fix-var-attrs branch 2 times, most recently from b8e89f5 to f968e2c Compare March 28, 2026 14:02
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.75%. Comparing base (0a4a3b6) to head (0659a92).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3379      +/-   ##
==========================================
+ Coverage   92.16%   95.75%   +3.59%     
==========================================
  Files         100      100              
  Lines        6125     6125              
==========================================
+ Hits         5645     5865     +220     
+ Misses        480      260     -220     
Flag Coverage Δ
api_func_v4 83.78% <ø> (?)
cli_func_v4 78.57% <ø> (ø)
unit 90.23% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
gitlab/v4/objects/variables.py 100.00% <ø> (ø)

... and 24 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant