Skip to content

fix(scenarios): stop wiping a scenario's interface on every update (WM-4599) - #91

Open
Uğur Oruç (Ketcap) wants to merge 1 commit into
mainfrom
fix/scenarios-update-wipes-interface-wm-4599
Open

fix(scenarios): stop wiping a scenario's interface on every update (WM-4599)#91
Uğur Oruç (Ketcap) wants to merge 1 commit into
mainfrom
fix/scenarios-update-wipes-interface-wm-4599

Conversation

@Ketcap

Copy link
Copy Markdown
Collaborator

[AI code generation]

Summary

  • normalizePayload no longer builds a default metadata: {input_spec: [], output_spec: []}; the key is emitted only when the caller supplies blueprint.interface or blueprint.io
  • Root cause: the empty arrays survived to the wire (JSON.stringify drops only undefined), and the backend's COALESCE(new_value, existing_value) only falls back on SQL NULL — so every unrelated scenarios_update (rename, folder move, scheduling tweak) silently cleared a scenario's on-demand inputs/outputs
  • Clearing an interface deliberately still works: pass an explicit interface: { input: [], output: [] }
  • Two existing update tests dropped their metadata: {input_spec: [], output_spec: []} expectation — that assertion encoded the bug

Fixes https://make.atlassian.net/browse/WM-4599

Test plan

  • npx tsc --noEmit passes
  • npx eslint passes on changed files (one pre-existing jest/expect-expect warning on an untouched test)
  • npx prettier --check passes on changed files
  • npx jest test/scenarios.spec.ts — 20/20 pass, including 4 new cases: no metadata on a plain rename; no metadata on a blueprint without an interface; interface hoisted into metadata when present; explicit empty interface still clears
  • Full npx jest run matches the pre-change baseline exactly (193 pre-existing integration-test failures, no live API key), with +4 passing

Copilot AI lite review requested due to automatic review settings August 31, 2026 20:19
@Ketcap
Uğur Oruç (Ketcap) requested a review from a team as a code owner August 31, 2026 20:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Stops scenarios.update()/scenarios.create() from unintentionally clearing a scenario’s on-demand interface by no longer emitting a default empty metadata.input_spec/metadata.output_spec unless an interface source is actually provided in the blueprint.

Changes:

  • Updated normalizePayload() to only include metadata when blueprint.interface or legacy blueprint.io is present.
  • Added/adjusted unit tests to verify metadata is omitted for non-interface updates and that explicit empty interfaces still clear as intended.
  • Minor test formatting cleanup.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/endpoints/scenarios.ts Makes metadata emission conditional so unrelated PATCH updates don’t wipe the scenario interface.
test/scenarios.spec.ts Updates existing expectations and adds new cases covering “no metadata unless interface is supplied” and “explicit empty interface clears”.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/scenarios.spec.ts
@Ketcap
Uğur Oruç (Ketcap) force-pushed the fix/scenarios-update-wipes-interface-wm-4599 branch from e524911 to 0c8cb71 Compare August 31, 2026 20:26
…M-4599)

normalizePayload always built `metadata: {input_spec: [], output_spec: []}` and
sent it on every PATCH, even when the caller passed no `interface`/`io`. The
backend's COALESCE only falls back to the existing value on SQL NULL, and an
empty array is not NULL, so any unrelated update — a rename, a folder move, a
scheduling tweak — silently cleared the scenario's on-demand inputs/outputs.
The key is now emitted only when the caller actually supplies one of those
sources; clearing on purpose still works via an explicit empty interface.
@Ketcap
Uğur Oruç (Ketcap) force-pushed the fix/scenarios-update-wipes-interface-wm-4599 branch from 0c8cb71 to d6c9ce8 Compare August 31, 2026 20:52
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.

2 participants