Repository navigation
packages/ak-common/config: coerce file:// and env:// values to their native type - #23758
Merged
rissson merged 1 commit intoJul 6, 2026
Conversation
…t type Values resolved from file:// and env:// references are inserted into the config tree as strings, so non-string fields (e.g. postgresql.port) failed to deserialize with `invalid type: string "5432", expected u16`. Direct AUTHENTIK_* environment variables avoid this because config_rs coerces them via try_parsing; file:// / env:// expansion runs afterwards on the already-built tree and bypasses that coercion. Add opt-in, target-type-aware deserializers on the non-string scalar fields (numeric and boolean), each accepting either a native value or a string. This fixes the reported class for both file:// and env:// while leaving string-typed fields untouched: a numeric-looking secret read from a file stays a string rather than being coerced to a number and rejected (which a blanket coerce-on-expand would do). The numeric helper is gated behind a sealed trait so it cannot be attached to a String field.
✅ Deploy Preview for authentik-storybook ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-integrations ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #23758 +/- ##
==========================================
- Coverage 93.23% 93.18% -0.05%
==========================================
Files 1039 1039
Lines 60848 60868 +20
Branches 424 424
==========================================
- Hits 56729 56721 -8
- Misses 4119 4147 +28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
rissson
approved these changes
Jul 6, 2026
rissson
added a commit
that referenced
this pull request
Jul 6, 2026
…native type (cherry-pick #23758 to version-2026.5) (#23759) Co-authored-by: Immanuel von Neumann <[email protected]>
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.
Details
What does this PR change?
Non-string config fields can now be supplied via
file://andenv://references without crashing the worker at startup.
Each non-string scalar field gets a deserializer that accepts either a native
value (YAML / direct env var) or a string (what a
file:///env://referenceresolves to).
String-typed fields are left untouched.
Why is this change needed?
Setting e.g.
postgresql.port: file:///run/secrets/pg-portcrashed the worker:A direct
AUTHENTIK_POSTGRESQL__PORT=5432env var works becauseconfig_rscoerces it to a number before it reaches the config tree.
file:///env://values are resolved later and arrive as strings, and
serde_jsonwon't coerce astring into
u16. This has been the case since the Rust config module was introduced,which replaced the Python loader's lenient handling with strict typed deserialization.
How was this tested?
Added unit test
config::tests::expand_typed: loads a config wherepostgresql.portis set viafile://andpostgresql.passwordvia afile://whose contents are the digits
12345, then assertsport == 5432(numeric fieldcoerced from the resolved string) and
password == "12345"(numeric-lookingstring field left untouched).
Local runs, all green:
cargo nextest run -p authentik-common→ 51/51 passed (incl.expand_typed).cargo +nightly fmt --all --check(ci-lint-rustfmt) → clean.cargo clippy -p authentik-common --all-targets -- -D warnings(ci-lint-clippy) → clean.cargo deny --locked --workspace check(ci-lint-cargo-deny) → ok.cargo machete(ci-lint-cargo-machete) → ok.End-to-end in a built image against the dev Postgres:
portviafile://bootsand runs migrations; a numeric-looking
passwordviafile://andenv://stays a string and connects.
Linked issues
closes #22908
Checklist
make all)make docs)