Repository navigation
refactor: return neverthrow results instead of hand-rolled ok/err unions - #416
Merged
Merged
Conversation
Contributor
File size check0 over a hard cap (fails), 30 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. |
…eady ship zod issue paths render through z.core.toDotPath at the four sites that each spelled their own join, so a key with a non-word character reads as ["my-key"] instead of .my-key. The secret scanning pattern comparison uses isDeepStrictEqual from node:util instead of JSON.stringify equality. The two set-equality helpers use Set.prototype.isSubsetOf, and the tsconfig lib moves from ES2022 to ES2025 for its types while the target stays ES2022. The REST query string is built by URLSearchParams, which writes a space as + where encodeURIComponent wrote %20; GitHub decodes both. Central-mode file names go through extname and parse from node:path instead of a YAML extension regex. valueAt has one home in the shared list-section module, the two environments modules share one unreconcilable message builder, and the generator scripts call RegExp.escape instead of a local escapeRe.
validateSecretRef returns Result<SecretRef, string> and resolveSecretRefs returns Result<ResolvedSecretRefs, string[]>, replacing the SecretRefCheck and SecretRefsResolution unions. redactSecretPayloadSafe returns Result<SafePayload, string | undefined>, the undefined error being the case that had no reason field: a non-JSON primitive or a hostile throw. parsePublicKey and parseStoredKey return Result<PublicKeyMaterial, string>, replacing the PublicKeyParse union. Every consumer reads isErr(), value, and error; every message is unchanged.
Vivswan
force-pushed
the
wt/lib-swaps
branch
from
September 22, 2026 09:53
42d050a to
ec6d9ed
Compare
Vivswan
force-pushed
the
wt/lib-swaps-results
branch
from
September 22, 2026 09:53
239231c to
b8020b6
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.
Stacked on #414 (base branch
wt/lib-swaps); merge that one first.What this changes
Three hand-rolled
{ ok: true, ... } | { ok: false, ... }unions become the neverthrowResultthe rest ofsrc/already returns. No message changes.How
isErr(),value, anderror; the twoBUG:throws (a minted snapshot reference the file would refuse, deploy key material that passed the shape but not the planner) keep their text.Result<SafePayload, string | undefined>, not a dedicated error type:undefinedis exactly the branch that had noreason(a non-JSON primitive, or a hostile object throwing during the reflective read), and the two callers inapi.tsword its fallback differently ("its payload" vs "its variables"), so the prose stays theirs.SecretRef,ResolvedSecretRefs,SafePayload,PublicKeyMaterial);bun run build:libbundles the declarations clean.toEqual(ok({ values, mask }))) where they used to read one field after anokcheck.Proof
bun test test/engine test/github test/sections-> 1911 pass, 0 fail (the message pins insecret-refs.test.ts,secrets.test.ts,deploy_keys.test.ts, andapi.test.tsare unchanged in text).bun run test:e2e --sections deploy_keys,actions_secrets-> 18/18.bun run build:libcompletes; no exported signature uses a private name.Technical details
Line accounting (
git diff --numstat wt/lib-swaps...HEAD, 11 files, +117/-132):Reviewer note, deliberately left as is:
src/github/api.tsClientAnswertri-state ({ data } | { failed } | ...) at 55 sites: a design-level swap, the owner's call.secret-scan.tsheader now says "transport-free" where it said "dependency-free": the module imports neverthrow, and the guarantee it states is independence from the transport.@actions/corein the CLI by recorded decision,matchesGlobsemantics, the twosrc/regex-escape copies, the tsconfiglibbump) is unchanged here.Codex rubber-duck: one round, no findings.
BEGIN_COMMIT_OVERRIDE
refactor: return neverthrow results instead of hand-rolled ok/err unions
validateSecretRef returns Result<SecretRef, string> and resolveSecretRefs returns Result<ResolvedSecretRefs, string[]>, replacing the SecretRefCheck and SecretRefsResolution unions.
redactSecretPayloadSafe returns Result<SafePayload, string | undefined>, the undefined error being the case that had no reason field: a non-JSON primitive or a hostile throw.
parsePublicKey and parseStoredKey return Result<PublicKeyMaterial, string>, replacing the PublicKeyParse union.
Every consumer reads isErr(), value, and error; every message is unchanged.
END_COMMIT_OVERRIDE