Skip to content

Fix - Template substitution with variable update#944

Merged
rochacbruno merged 6 commits intodynaconf:masterfrom
pedro-psb:bug/template-substitution-with-envvar
Jun 30, 2023
Merged

Fix - Template substitution with variable update#944
rochacbruno merged 6 commits intodynaconf:masterfrom
pedro-psb:bug/template-substitution-with-envvar

Conversation

@pedro-psb
Copy link
Copy Markdown
Member

This fixes the misbehavior of template substitution when the variable to be substituted gets updated by another source, as described in #575 #603 #666 and #690

Main changes:

  • avoid replacement of Lazy objects by it's value inside parse_conf_data
  • add _safe_get and _safe_items methods to DynaBox.
  • small unrelated refactors

Problem Overview

There were some points where earlier evaluation was called internally. Although those calls were unnecessary, they shouldn't have cause this bug by itself because evaluating a Lazy object means only asking it to return the final value (it doesn't replace itself with the value), so later on it should have used the correct value. Nevertheless, parse_conf_data was replacing the Lazy object with its early evaluation value, and that was the main cause of the problem.

Additional Notes

Related to this, it would be nice to:

@netlify
Copy link
Copy Markdown

netlify bot commented Jun 29, 2023

Deploy Preview for dynaconf ready!

Name Link
🔨 Latest commit dd80327
🔍 Latest deploy log https://app.netlify.com/sites/dynaconf/deploys/649e1b13ea2e6e0008cab565
😎 Deploy Preview https://deploy-preview-944--dynaconf.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 29, 2023

Codecov Report

❌ Patch coverage is 90.90909% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.64%. Comparing base (f0d9665) to head (dd80327).
⚠️ Report is 146 commits behind head on master.

Files with missing lines Patch % Lines
dynaconf/utils/boxing.py 50.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #944      +/-   ##
==========================================
- Coverage   99.79%   99.64%   -0.15%     
==========================================
  Files          22       22              
  Lines        1976     1994      +18     
==========================================
+ Hits         1972     1987      +15     
- Misses          4        7       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@rochacbruno rochacbruno merged commit c4f48ea into dynaconf:master Jun 30, 2023
@pedro-psb pedro-psb deleted the bug/template-substitution-with-envvar branch June 30, 2023 13:04
pedro-psb added a commit to pedro-psb/dynaconf that referenced this pull request Jul 13, 2023
Shortlog of commits since last release:

    Bruno Rocha (4):
          Ignore docs build without a tag
          Cancel any running CI job when a Push is made to an existing PR or branch (dynaconf#952)
          Fix dynaconf#959 cli get will exit code 1 in case of KeyError. (dynaconf#960)
          add tech preview note to inspect docs (dynaconf#961)

    Pedro Pessoa (9):
          Docs - Update envvar.md custom token e.g. to use add_converter (dynaconf#941)
          Feature - Inspect and CLI (dynaconf#939)
          Fix - Template substitution with variable update (dynaconf#944)
          Assert dynaconf#658 works (dynaconf#945)
          fix infinite recursions in special case of django app dynaconf#867 (dynaconf#947)
          Fix - Django functions with `add_converter` (dynaconf#951)
          Fix hooks not re-running on reload dynaconf#850 (dynaconf#953)
          update vault and redis warning recommendations. fix dynaconf#950 (dynaconf#954)
          Fix - Enable merge equal False (dynaconf#957)
rochacbruno added a commit that referenced this pull request Aug 11, 2023
Shortlog of commits since last release:

    Bruno Rocha (5):
          Ignore docs build without a tag
          Cancel any running CI job when a Push is made to an existing PR or branch (#952)
          Fix #959 cli get will exit code 1 in case of KeyError. (#960)
          add tech preview note to inspect docs (#961)
          Build docs

    Hugo Prudente (1):
          Doc advanced usage for cli overrides dynaconf settings fix #967 (#970)

    Marian Ganisin (1):
          Feat: Support for multidoc yaml files (#825)

    Pedro Pessoa (11):
          Docs - Update envvar.md custom token e.g. to use add_converter (#941)
          Feature - Inspect and CLI (#939)
          Fix - Template substitution with variable update (#944)
          Assert #658 works (#945)
          fix infinite recursions in special case of django app #867 (#947)
          Fix - Django functions with `add_converter` (#951)
          Fix hooks not re-running on reload #850 (#953)
          update vault and redis warning recommendations. fix #950 (#954)
          Fix - Enable merge equal False (#957)
          CI - Test docker-compose pyyaml issue (#964)
          Fix: unexpected _bypass_evaluation in BoxList (#966)

    pedro-psb (1):
          Release version 3.2.0
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.

3 participants