Skip to content

fix(env): the runtime environment file admits a configuration document carrier - #95

Merged
antoinetoussaint-byte merged 2 commits into
mainfrom
fix/runtime-file-admits-document-carrier
Oct 30, 2026
Merged

antoinetoussaint-byte merged 2 commits into
mainfrom
fix/runtime-file-admits-document-carrier

Conversation

@antoinetoussaint-byte

@antoinetoussaint-byte antoinetoussaint-byte commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Symptom

platform-core's composition gate (and the cli#1256 work) fails a native run with output environment record 51: its name is not uppercase ASCII, digits and underscores. The record is CODEFLY__CONFIGURATION_DOCUMENT_V1__5023386c…e765, the carrier of the workspace's fixture-composition document (digest of ["_workspace_origin","fixture-composition","local"]) that saas/auth-gateway receives. The CLI's --output-env writer refuses it because it mirrors this reader's grammar byte for byte, and this reader refuses the whole artifact.

Cause

core names a structured configuration document's carrier CODEFLY__[SECRET_]CONFIGURATION_DOCUMENT_V1__ + a lowercase hex SHA-256 (resources.ConfigurationDocumentKey). validRuntimeEnvironmentName accepts only [A-Z0-9_] after CODEFLY__. The two never agreed: no --output-env file carrying a document could ever load.

Fix (a fix, at the reader that owns the file grammar)

validRuntimeEnvironmentName also admits exactly the document carrier core mints: one of the two document prefixes (core's constants) and exactly 64 lowercase hex digits. Any other lowercase name is still refused.

Why not upper-case the digest in core instead: this SDK reads the document by calling resources.ConfigurationDocumentKey and looking the result up exactly (configurationDocument: injected value, os.LookupEnv, then FindValueInEnvironmentVariables, all case-sensitive). Every consumer built on a core that mints the lowercase name would miss an upper-cased carrier and report ErrConfigurationDocumentMissing. Widening the file grammar to the name core already mints changes no carrier name anywhere.

Companion CLI change (the writer accepts the same shape): codefly-dev/cli#1260. Merge this first: the CLI's writer is held to this reader's grammar.

Tests

  • TestLoadRuntimeEnvironmentFileCarriesAConfigurationDocument: core's own manager emits the document, the file is loaded, and WorkspaceConfigurationDocument("fixture-composition") returns it.
  • TestLoadRuntimeEnvironmentFileAdmitsOnlyTheDocumentDigestInLowerCase: both prefixes admitted; 63/65 digits, non-hex, a V2 prefix, another carrier with a hex tail, CODEFLY__lower and a lowercase prefix refused.
  • Both fail with the new branch disabled. go test ./... and golangci-lint run (0 issues) pass locally.

Reused: core's ConfigurationDocumentPrefix / SecretConfigurationDocumentPrefix. Not done: no compat lookup for an upper-cased digest, because nothing mints one.

🤖 Generated with Claude Code

…t carrier

core names a structured configuration document's carrier with a lowercase
hex SHA-256 (resources.ConfigurationDocumentKey), and LoadRuntimeEnvironmentFile
accepted only [A-Z0-9_] after CODEFLY__, so an --output-env artifact carrying
one (a composition's workspace fixture-composition document) could never load.
Admit exactly that shape: a document prefix and 64 lowercase hex digits. The
name is kept rather than upper-cased in core because this SDK, and every
consumer built on an earlier core, finds the document by calling that same
function and looking the result up exactly.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The reader imported crypto/sha256 and encoding/hex only to spell a length,
which the deny-by-default import gate (scripts/allowed-imports.txt) refuses
outside the files that hash. Read the length from core's own
ConfigurationDocumentKey instead: no new import, and it follows core if the
digest ever changes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
antoinetoussaint-byte added a commit to codefly-dev/cli that referenced this pull request Oct 30, 2026
Mirror codefly-dev/sdk-go#95: read the digest length from core's own
ConfigurationDocumentKey instead of spelling a SHA-256 length here, so the
writer and the reader derive the shape the same way.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@antoinetoussaint-byte
antoinetoussaint-byte merged commit 92cde97 into main Oct 30, 2026
16 checks passed
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