credentialFile: an embedded string placeholder is refused, but the egress proxy substitutes sentinels as substrings #1508
Notifications
Due Date
No due date set.
Depends on
Reference: sam/archie#1508
Reference in new issue
Block a user
Found while reviewing archie-core-egkf.14, which merged the scopes and primaryApiKey rendering.
egkf.14 refuses a value placeholder embedded in a larger string ("must be a field's whole value"), calling it a fail-closed reading of a shape the spec does not define. egkf.13 had accepted that shape ("whole value or inside a larger string").
The refusal is not required by the mechanism it protects. The egress proxy substitutes the sentinel as a SUBSTRING, not as an exact value:
So "Bearer {{.AccessToken}}" renders to a sentinel that the proxy still finds and swaps, and the container never sees a real token either way.
Decide: restore embedding for the STRING placeholders (AccessToken, RefreshToken, PrimaryApiKey), where the proxy supports it and egkf.13 supported it; and keep the refusal for the TYPED ones ({{.Scopes}}, an array), where embedding is genuinely ill-defined because the leaf has no string form. That is a narrower, better-grounded rule than refusing both.
Evidence to keep: the proxy's substring semantics above, and egkf.14's test that pins the current refusal so a change is deliberate.
Imported from beads
archie-core-pa4q· GitHub #1386 · type task · priority P3 · created 2026-09-29Triaged: no code change is needed for this. No code change: the rule the issue asks for is already the shipped rule for the placeholders the proxy actually substring-substitutes.
Embedding is not refused for AccessToken/RefreshToken.
internal/infrastructure/kit/credential_file.go:99runsspliceSentinelson every non-exact string leaf, and:135-147replaces{{.AccessToken}}and{{.RefreshToken}}inside a larger string, so"Bearer {{.AccessToken}}"renders to"Bearer <sentinel>"today. egkf.14 refuses only the typed/omitted leaves, not the token ones.What is refused is
{{.ExpiresAt}},{{.Scopes}},{{.PrimaryApiKey}}embedded (credential_file.go:155-166).{{.Scopes}}is the array the issue wants refused;{{.ExpiresAt}}is an int64 epoch-ms (:37-40), so it belongs with the typed ones too, not the string ones.The proxy evidence in the issue checks out, and matches the code above:
headerCarriesusesstrings.Contains(egress/oauth.go:300-309),injectOAuthReplaceAlls every header value (oauth.go:148-152),interceptOAuthdoesbytes.Contains/bytes.ReplaceAllon the token body (oauth.go:168-172).The one residual ask — embedding
{{.PrimaryApiKey}}— is not a value placeholder here.credential_file.go:18-20and:61-63treat it as the spec's omission marker and drop the enclosing key. It also is not substring-substituted by the proxy: API keys are injected by overwriting the header from the Kit's own rule (egress/credentials.go:113,r.Header.Set(rule.header, fmt.Sprintf(rule.format, secret))) under a single shared sentinel constant (credentials.go:18,SentinelEnvat:118-128). A sentinel spliced into a file string would reach upstream literally unless the Kit's inject rule names the same header, so restoring that embedding would not do what the issue expects.Not verified: the
sandbox-kit-spec/v3 v3.0.0-m.8source (go.mod:78) — outside this worktree. The omit-marker reading of{{.PrimaryApiKey}}rests on the in-repo comment atcredential_file.go:18-19, not on the spec text.The evidence the issue asks to keep does not exist. No test covers
credential_file.go:kit_test.gohas three tests, and its only credential-file fixture (kit_test.go:196) uses a whole-value{{.AccessToken}}and asserts only that the file is present (:207-213). Nothing pins the"must be a field's whole value"refusal, so egkf.14's pinning test was never committed in this tree.Follow-up not started: add the missing pins — embedded AccessToken/RefreshToken accepted with the sentinel spliced in, embedded Scopes/ExpiresAt/PrimaryApiKey refused. If the operator instead wants
{{.PrimaryApiKey}}treated as a rendered string rather than an omission marker, that is a spec question to settle before code, not a defect.