Skip to content

[finding] service-automation: the local TryCatchErrorValue & { code?: string } widening in try-catch-node.ts becomes redundant once packages/spec declares code (#14954 follow-up) #15669

Description

@claude

Blocked-by: #14954

Filed by the domain:spec execution seat for #14954 as an out-of-scope observation. Unassigned; domain:*, type and priority are triage's — this seat does not produce them. Observation class (a redundancy, not a defect): the code compiles and behaves correctly both before and after #14954 lands.

What

packages/services/service-automation/src/builtin/try-catch-node.ts (at origin/main 7087f99c, around :221-:240) builds the catch-region binding as an explicit local widening of the spec type:

const errorValue: TryCatchErrorValue & { code?: string } = {
  nodeId: node.id,
  message: lastError,
  ...(lastErrorCode ? { code: lastErrorCode } : {}),
  ...(loopFrame ? { iteration: loopFrame.iteration, item: loopFrame.item } : {}),
};

Its own comment says why: code (#14419) was bound alongside but was NOT declared on TryCatchErrorValueSchema, so it was spelled as an explicit widening rather than dropped, and the divergence was filed as #14954 against the spec lane.

Why it is now redundant

#14954 (the spec half, branch claude/issue-14954-try-catch-error-code-key) declares code: z.string().optional() on TryCatchErrorValueSchema, so the exported TryCatchErrorValue type already carries code?: string. The intersection TryCatchErrorValue & { code?: string } is then the same type as TryCatchErrorValue; it still compiles (measured: pnpm --filter @objectstack/service-automation typecheck exit 0 against the rebuilt spec dist), so nothing is broken — but the annotation and the comment paragraph explaining the widening now describe a divergence that no longer exists, which is exactly the kind of stale explanation the next reader will act on.

Suggested shape (for the domain:services seat, not a ruling)

Once #14954 has landed: annotate errorValue as plain TryCatchErrorValue, and rewrite the comment paragraph that begins code (#14419) is bound alongside but is NOT declared on TryCatchErrorValueSchema to state that the key is declared (pointing at the spec docblock). No behaviour change; no changeset needed beyond what the services lane's own convention asks for a comment-and-annotation edit.

⛔ Not done in #14954's PR: that file is domain:services and was in flight under the services lane's cards (#15616 / #15572) at dispatch time; the spec card was scoped to packages/spec and its generated followers only.

Refs: #14954 (the spec half) · PR #14948 / #14419 (the engine half that introduced the widening) · #14955 (the related but distinct $error refresh asymmetry finding)


Generated by Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions