Skip to content

fix: resolve secret references in nested pydantic model fields#41

Merged
discreteds merged 6 commits into
developfrom
feature/nested-secrets-resolution
May 6, 2026
Merged

fix: resolve secret references in nested pydantic model fields#41
discreteds merged 6 commits into
developfrom
feature/nested-secrets-resolution

Conversation

@discreteds

Copy link
Copy Markdown
Member

Summary

  • Fix unresolved secret: references in nested model fields (e.g., AuthSpec subclasses) loaded from YAML config files
  • Separate general reference resolution mechanism (resolve.py) from secrets domain (secrets/)
  • Rename functions: resolve_secrets_in_dictresolve_references_in_dict, resolve_secrets_on_instanceresolve_references_in_model_tree
  • Handle frozen nested models (like AuthSpec) via dict extraction + rebuild instead of in-place mutation

Test plan

  • 18 unit tests in tests/unit/test_resolve.py covering flat fields, nested models, frozen models, deep nesting, and no-rebuild optimization
  • 2 integration tests in tests/test_base_settings.py covering frozen PasswordAuth with secrets from YAML and from kwargs
  • Verify old secrets.resolve module raises ModuleNotFoundError
  • Verify public API (SecretsResolver, registry functions) unchanged
  • 421 total tests passing, ruff clean

🤖 Generated with Claude Code

discreteds and others added 6 commits May 6, 2026 10:58
Addresses gap where secret: prefixed values in nested pydantic models
(e.g., AuthSpec fields loaded from YAML) are not resolved. Separates
general reference resolution mechanism from secrets domain.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6 tasks: create resolve.py with recursive model tree walking, rewire
call sites, delete secrets/resolve.py, integration tests, principles
update, final verification.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
General-purpose reference resolution separated from secrets domain.
resolve_references_in_dict handles nested dicts, resolve_references_in_model_tree
handles pydantic model trees including frozen nested models via rebuild.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
All three interception points now import from the general-purpose
resolve module instead of the secrets-specific one.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Delete the old secrets-specific resolution module and its tests.
Update secrets/__init__.py docstring to clarify scope.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests frozen AuthSpec (PasswordAuth) with secret: prefixed values
loaded from YAML and from kwargs — both resolve correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented May 6, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
E Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@codecov

codecov Bot commented May 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.49123% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.07%. Comparing base (cbe4f98) to head (4f14125).
⚠️ Report is 1 commits behind head on develop.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/mountainash_settings/resolve.py 96.07% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop      #41      +/-   ##
===========================================
+ Coverage    96.90%   97.07%   +0.16%     
===========================================
  Files           36       36              
  Lines          938      958      +20     
  Branches       123      130       +7     
===========================================
+ Hits           909      930      +21     
+ Misses          16       15       -1     
  Partials        13       13              

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

@discreteds discreteds merged commit 2abafac into develop May 6, 2026
4 of 6 checks passed
@discreteds discreteds deleted the feature/nested-secrets-resolution branch May 6, 2026 02:55
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