Skip to content

fix(api): answer 404 for a missing flow, element or pad on the property endpoints - #1162

Merged
srperens merged 1 commit into
mainfrom
fix/928-property-404
Oct 28, 2026
Merged

srperens merged 1 commit into
mainfrom
fix/928-property-404

Conversation

@srperens

Copy link
Copy Markdown
Collaborator

Closes #928

Problem

The four element and pad property endpoints (GET/PATCH .../elements/{element_id}/properties and .../pads/{pad_name}/properties) document 404 for a flow that is not running and for a missing element or pad. They answered 400 for every error, so a client could not tell "not there" from "bad value". A flow that does not exist was reported as Invalid flow: Pipeline not running, the same error a bad flow definition gives elsewhere. Checked on current main with read-only GETs: a missing flow and a stopped flow both answered 400 on both endpoints.

Change

  • New PipelineError::FlowNotRunning. The four state lookups (update_element_property, get_element_properties, update_pad_property, get_pad_properties) return it instead of InvalidFlow when the flow has no pipeline.
  • property_error_status() in api/flows.rs maps FlowNotFound, FlowNotRunning, ElementNotFound and PadNotFound to 404, and everything else to 400 (InvalidProperty, PropertyNotMutable, ...). The four handlers use it. The 500 for "updated but failed to read back" is unchanged.

Rejected: reusing FlowNotFound for a stopped flow. The flow exists, and the message would say it doesn't.

Evidence

  • Missing flow, stopped flow, missing element, missing pad answer 404 on GET and PATCH; an unknown property name still answers 400; reads on an existing element and pad answer 200: property_not_found_status_test::missing_flow_element_or_pad_answers_404. With the backend/src changes reverted it fails on its first call: GET /api/flows/00000000-0000-4000-8000-000000000928/elements/src/properties answered 400 Bad Request, expected 404 Not Found.
  • The OpenAPI schema does not change: 404 was already documented. openapi_test passes without updating openapi.json.

Tests

Ran on macOS (GStreamer 1.28.6):

  • cargo test --test property_not_found_status_test --test openapi_test: both pass.
  • The new test with the fix reverted: fails as quoted above.
  • cargo clippy --all-targets: clean.

The new test needs videotestsrc (plugins-base) and fakesink (core), which every CI test job installs. It does not skip.

Not run: the full backend test suite locally.

For the reviewer

  • The error text from these four lookups changes from Invalid flow: Pipeline not running for flow: <id> to Flow not running: <id>. The MCP get_element_properties / update_element_property tools pass it through as text. Nothing in the repo matches on the old text.
  • A missing flow and a stopped flow both answer 404 Flow not running: the state lookup only sees the running pipelines.

Out of scope

Ten other state methods still report a stopped flow as InvalidFlow("Pipeline not running ...") (vision mixer, loudness, recorder split, ...). Their handlers are not part of #928 and map errors their own way.

🤖 Generated with Claude Code

https://claude.ai/code/session_0199NeykvEJAk7jqit4PwX4J

…ty endpoints

The four element and pad property endpoints documented 404 for a flow that
is not running and for a missing element or pad, but mapped every error to
400. The state layer also reported a missing or stopped flow as an invalid
flow. A stopped flow is now FlowNotRunning at those four lookups, and the
handlers map the not-found errors to 404. Bad values and properties that
cannot change stay 400.

Closes #928

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0199NeykvEJAk7jqit4PwX4J

@srperens srperens left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Area: REST API, error status codes on the property endpoints

The PR adds a typed PipelineError::FlowNotRunning and property_error_status (backend/src/api/flows.rs:1128), which maps a missing flow, pipeline, element or pad to 404 by variant, not by message text, across all four handlers. That is the right fix. The GET annotations now match what the handlers return.

Neighbours: #806 edits other hunks of flows.rs and state/mod.rs; I did not check a merge. #1154 regenerates openapi.json, which this PR leaves alone.

I found nothing wrong in the change. The test drives the real router through all four endpoints, should fail if the fix is reverted, and uses only core/base elements, so it runs in CI.

Out of scope here, but the same problem remains elsewhere:

  1. At this head, 14 other state methods still return InvalidFlow("Pipeline not running for flow: ...") (the PR body says ten). Their endpoints keep answering 400.
  2. get_block_thumbnail picks 404 by string match (flows.rs:2599). Both could reuse FlowNotRunning in a follow-up.

@srperens
srperens merged commit 4881971 into main Oct 28, 2026
10 checks passed
@srperens
srperens deleted the fix/928-property-404 branch October 28, 2026 14:20
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.

Property endpoints return 400 for a missing element or pad, but document 404

1 participant