Skip to content

fix(protocol): add literal discriminator to ScheduleValidationError - #247

Open
alltomatos wants to merge 6 commits into
devfrom
fix/schedule-validation-error-discriminator
Open

alltomatos wants to merge 6 commits into
devfrom
fix/schedule-validation-error-discriminator

Conversation

@alltomatos

Copy link
Copy Markdown
Owner

Issue for this PR

Closes #245

Type of change

  • Bug fix

What does this PR do?

bun run check:generated (part of unit (linux)/unit (windows) CI) fails with:

error: Promise error must have a literal discriminator: server.schedule.schedule.create
    at assertPromiseEndpoint (packages/httpapi-codegen/src/index.ts:296:13)

This was masked on dev until now — CI was failing earlier, at the formatMinutes locale unit-test step (#236/#237), so check:generated never ran far enough to reach this. Once that's fixed, this surfaces on every PR.

Root cause: ScheduleValidationError in packages/protocol/src/groups/schedule.ts was missing the literal discriminator field (name/_tag) that httpapi-codegen's declaredErrorFields() requires on every HttpApi error class. Every sibling error class (e.g. ProjectCopyError) declares name: Schema.Literal("<ClassName>"); ScheduleValidationError was the one outlier.

Fix:

  • Added name: Schema.Literal("ScheduleValidationError") to the error class's fields.
  • Updated both construction sites in packages/server/src/handlers/schedule.ts to pass name: "ScheduleValidationError", matching the ProjectCopyError pattern exactly.

How did you verify your code works?

  • tsgo --noEmit on packages/protocol and packages/server: clean, 0 errors.
  • oxlint on both changed files: 0 warnings, 0 errors.
  • Reproduced the original failure locally with bun@1.3.14 (pinned version) by running bun run script/build.ts from packages/client on a clean checkout — confirmed error, then confirmed it's gone after this fix (the schedule.schedule.create discriminator error no longer occurs).

Note: bun run check:generated still doesn't fully pass on dev after this fix alone — fixing this uncovers a further masked issue (HttpApiError.BadRequest in system.ts produces an invalid TS identifier), filed separately as #246 since it's an unrelated root cause in a different file. This PR is scoped to the ScheduleValidationError fix only.

Screenshots / recordings

N/A — server/protocol-only change, no UI.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

This PR was opened by an unattended scheduled sync run — please review before merging.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SHQKcGH7ayRe8UHJ9CAPQJ


Generated by Claude Code

httpapi-codegen requires every HttpApi error class to declare a literal
`name`/`_tag` field (see declaredErrorFields in packages/httpapi-codegen).
ScheduleValidationError was the one error class missing it, which fails
bun run check:generated with "Promise error must have a literal
discriminator: server.schedule.schedule.create". Matches the existing
ProjectCopyError pattern.

Closes #245
Companion change for the protocol-side fix: both construction sites now
supply the newly-required `name` literal field.

Closes #245
…ependent

Ported from #237 (not yet merged to dev) to unblock this PR's own CI —
same base-branch-wide failure documented on #241. No-ops once dev carries #237.
Ported from #237. Companion to the stats-controller.ts change.
Ported from #237. Companion to the stats-controller.ts change.

Copy link
Copy Markdown
Owner Author

unit (linux) failed on the first push here with the same base-branch-wide formatMinutes locale bug documented on #241 (this branch was cut from dev before #237 landed). Ported #237's fix into this branch too (3 commits above) so this PR's own CI isn't blocked by it — no-ops once dev carries #237.


Generated by Claude Code

…id_idx

Ported from #240 (not yet merged to dev) to unblock this PR's own CI —
same base-branch-wide failure documented on #241. No-ops once dev carries #240.
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.

check:generated fails on dev: ScheduleValidationError missing literal discriminator

1 participant