Skip to content

fix(schedules): enforce resonate:target in LocalNetwork schedule.create - #9

Open
flossypurse wants to merge 1 commit into
mainfrom
fix/local-network-schedule-target-validation
Open

fix(schedules): enforce resonate:target in LocalNetwork schedule.create#9
flossypurse wants to merge 1 commit into
mainfrom
fix/local-network-schedule-target-validation

Conversation

@flossypurse

Copy link
Copy Markdown
Contributor

Addresses the second checklist item of #6 — "LocalNetwork enforces the server's create-time validation so tests catch this class of regression."

Why

Since server v0.9.7, schedule.create rejects a request whose promiseTags lack a resonate:target tag with HTTP 400 (validate_schedule_create_data, resonate/src/types.rs:641-643) — every promise a schedule fires needs a routing target or no worker group receives it. LocalNetwork did not run that validation, so a create the real server rejects succeeded in local mode. That's exactly why the original schedule() bug (#6, fixed in #7) passed its unit tests: the in-process network never enforced the tag.

Change

  • Network.ServerState.scheduleCreate throws ServerError(400, "promiseTags must include a resonate:target tag") when promiseTags is absent or lacks the key, before the idempotency short-circuit — mirroring the server, where request validation runs before the handler.
  • SchedulesTest: the two low-level create tests that passed empty tags now pass a resonate:target (they'd otherwise fail against a real server, which is the point); adds createWithoutResonateTargetIsRejected asserting the 400. The high-level Resonate.schedule() tests are unaffected — fix(schedules): inject resonate:target into schedule promise tags #7 already injects the tag.

Verification

./gradlew spotlessCheck test — green. SchedulesTest now 5 (was 4), 0 skipped; full suite passes.

Scope note: this mirrors only the resonate:target check — the same validator's schedule-ID-dot rule is a separate gap and left for a focused follow-up.

A real server rejects a schedule.create whose promiseTags lack a
resonate:target tag (400) — every fired promise needs a routing target.
LocalNetwork did not run that validation, so a create the server would
reject succeeded in local mode and this regression class slipped past the
LocalNetwork-backed unit tests.

- Network.ServerState.scheduleCreate now throws ServerError(400,
  "promiseTags must include a resonate:target tag") when promiseTags is
  absent or lacks the key, before the idempotency check — mirroring the
  server's validate-first order.
- SchedulesTest: the two low-level create tests that passed empty tags now
  pass a resonate:target (they would otherwise fail against a real server);
  add createWithoutResonateTargetIsRejected asserting the 400.

Addresses the second checklist item of #6.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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