Skip to content

errors/5 resource delete problem - #97

Merged
JosteinGj merged 1 commit into
mainfrom
errors/5-resource-delete-problem
Sep 16, 2026
Merged

JosteinGj merged 1 commit into
mainfrom
errors/5-resource-delete-problem

Conversation

@JosteinGj

Copy link
Copy Markdown
Contributor

What this changes

How it was verified

Checklist

  • Pull requests this one depends on are named above and merged first, or there are none
  • Commits are signed off (git commit -s), per CONTRIBUTING.md
  • ./gradlew build passes
  • Behaviour visible outside this repo is reflected in the documentation, or does not need to be
    (see AGENTS.md for which of the two documentation sites it belongs in)

@JosteinGj
JosteinGj added this pull request to stack #99 September 15, 2026 09:17
@olavgg
olavgg force-pushed the errors/5-resource-delete-problem branch from bcde487 to 1ac4edc Compare September 15, 2026 13:26
@JosteinGj
JosteinGj force-pushed the errors/5-resource-delete-problem branch from 1ac4edc to 8e675bb Compare September 16, 2026 07:40
@JosteinGj
JosteinGj force-pushed the errors/5-resource-delete-problem branch from 8e675bb to 48e4ede Compare September 16, 2026 07:50
@JosteinGj
JosteinGj marked this pull request as ready for review September 16, 2026 07:51
@JosteinGj
JosteinGj requested a review from olavgg as a code owner September 16, 2026 07:51
stack merge was automatically disabled September 16, 2026 07:57

Pull Request is not mergeable

@JosteinGj
JosteinGj force-pushed the errors/5-resource-delete-problem branch from 48e4ede to 8bf329f Compare September 16, 2026 08:02
@JosteinGj
JosteinGj force-pushed the errors/5-resource-delete-problem branch from 8bf329f to 0af1de0 Compare September 16, 2026 08:11
@JosteinGj
JosteinGj force-pushed the errors/5-resource-delete-problem branch from 0af1de0 to 7460a09 Compare September 16, 2026 08:14
Base automatically changed from errors/4-hand-rolled-bodies to main September 16, 2026 08:24
…ailure

ResourceDeleteException was the last exception in the API still answering
in the ResponseError envelope. Seven controllers caught it and returned
the body it carried, so a client that had moved to problem+json for
everything else still had to special-case delete.

An eighth never caught it: POST /policies/delete reaches the same graph
guards through PolicyService.deletePolicies, so a refused policy delete
came back as a bare 500 naming nothing. That is what handling it in one
place fixes, rather than writing the missing catch.

The status moves 400 -> 409. Nothing is wrong with the request: it is
well-formed, the ids exist, and it will succeed verbatim once the
subscription is removed or the stranded nodes are included. That is a
conflict with the current state, and it puts a refused delete next to the
API's other 409s — a taken external id, a lost optimistic lock — which
are the same "retry once the world changes" answer. A 400 told clients to
fix a payload that was never the problem.

The exception now carries the facts instead of a rendered body: a type
URI (referenced / would-strand — the two guards want different things
from the caller), the detail, and the blockers. The blockers keep their
own `blockedBy` member rather than going through the field -> message
bridge, which would turn one subscription into four unrelated field
errors and lose the external id the caller needs to go and delete.

  {"error":{"code":400,"message":"...","fields":[{"type":"subscription",...}]}}

becomes

  {"type":"https://intellistream.ai/errors/referenced",
   "title":"Delete refused","status":409,"detail":"...",
   "blockedBy":[{"subscriptionId":"9","subscriptionExternalId":"sub_a",
                 "timeseriesId":"5"}]}

The OpenAPI moves with it. Seven delete endpoints now document a single
409 covering both the refusal and the optimistic-lock conflict, told
apart by `type`; /resources/delete and /timeseries/delete lose the 400
that described the refusal with a BadRequestError example.

EventController is the exception: EventService.delete is ClickHouse,
KVRocks and Pulsar only and never reaches the graph guards, so its catch
was dead code and its docs need no 409.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: jgjesdal <jostein@intellistream.ai>
@JosteinGj
JosteinGj force-pushed the errors/5-resource-delete-problem branch from 7460a09 to 7fbbb56 Compare September 16, 2026 08:24
@JosteinGj
JosteinGj merged commit 9459a0e into main Sep 16, 2026
8 of 9 checks passed
@JosteinGj
JosteinGj deleted the errors/5-resource-delete-problem branch September 16, 2026 08:33
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