Repository navigation
refactor(sections): give secretValuesOf a typed signature and drop the container checks it made necessary - #468
Merged
Merged
Conversation
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
Validated extraction inputs and function-only gated callers support the removed checks, with no unresolved defects identified.
Review effort: Balanced
Findings: None
What changed in this PR
This refactor uses typed section entries for secret extraction, removing redundant runtime checks while preserving validation at the engine boundary.
Changes:
- Give secret extraction helpers typed list signatures.
- Restrict gated ports to function members.
- Update tests to cover supported inputs rather than malformed values passed through casts.
| File | Description |
|---|---|
| test/sections/webhooks/webhooks.test.ts | Remove malformed-container expectations. |
| test/sections/environments/environments.test.ts | Retain coverage for supported nested secret forms. |
| src/sections/shared/secrets-engine.ts | Type secret lists and simplify extraction. |
| src/sections/shared/list-section.ts | Pass the erased declared-list type to extraction. |
| src/sections/environments/index.ts | Use typed environment entries without casts. |
| src/sections/contract/plan.ts | Constrain gated helpers to functions. |
| src/sections/contract/module.ts | Make secret extraction generic and reuse listEntries. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
File size check0 over a hard cap (fails), 10 warning(s).
Split the file, wrap the line, shorten or exempt the comment, or list the path in 5 managed file(s) skipped; repo-platform owns them. |
…e container checks it made necessary secretValuesOf took `unknown` and re-proved the container and each entry with typeof and Array.isArray checks, because the erased list-section path once fed it an erased value. Every producer now hands it zod's output: validateSectionShapes calls the hook only after the shape parse succeeded, and collectSecretReferences takes the validated document. The function takes the declared list form listEntries() already models, so the extract callback receives the section's own entry type. The callers pass the typed value and lose their twins of the shape parse: listSecretValues no longer checks that name and value are strings, the environments hook no longer casts the entry or guards its name, and secretValuesFor passes the erased declared value instead of unknown while keeping the narrowings valueAt()'s erased walk needs. gated() in plan.ts constrains its parameter to an object whose members are all functions and drops the typeof branch both call sites could never take. The two tests that fed secretValues malformed containers through double casts had no producer left to pin: the webhooks one is deleted and the environments one keeps only the typed inputs. A caller that violates the type with null or a scalar now gets a TypeError from listEntries instead of an empty list; the type is the fix.
Vivswan
force-pushed
the
refactor/secret-values-typed
branch
from
October 5, 2026 10:58
f4c4133 to
b245875
Compare
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.
What this changes
How
SecretEntry[] | UndeclaredPolicyList<SecretEntry>and drops its string checks on name and value.secretsbranch.ErasedDeclaredand keeps the narrowings valueAt()'s erased walk needs.typeof helperbranch neither call site could take.anynow gets a TypeError from listEntries instead of an empty list. The type is the fix. A scalar still returns[]as before.Proof
Technical details
declared: unknown1 -> 0.declared: unknown1 -> 0, typeof 2 -> 2 (the valueAt narrowings stay).declared: unknown1 -> 0.declared: unknown1 -> 0.typeof helper1 -> 0.as unknown ascasts feeding secretValues 2 -> 0 in environments.test.ts, 1 -> 0 in webhooks.test.ts.{entries}wrapper, and an entry without secrets, which are the three real nested forms.secretValues?(declared: unknown)cast, the engine's documented re-widening of the registry's generic view.unknownthe erased path walk returns, so they are not twins of the shape.any.src/sections/contract/{module.ts,plan.ts},src/sections/shared/{list-section.ts,secrets-engine.ts},src/sections/environments/index.ts,test/sections/{environments/environments.test.ts,webhooks/webhooks.test.ts}.