Skip to content

fix(objects): the routes catch what they were written to catch - #5883

Merged
rubenvdlinde merged 4 commits into
developmentfrom
fix/objects-catch-what-was-meant
Nov 6, 2026
Merged

rubenvdlinde merged 4 commits into
developmentfrom
fix/objects-catch-what-was-meant

Conversation

@rubenvdlinde

@rubenvdlinde rubenvdlinde commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

This changes visible behaviour on purpose.

ObjectsController imported OCP\DB\Exception, so five catch (Exception) blocks took database failures only. Every other failure left the route. Each block now catches what it was written to catch. Database failures get the same responses as before.

Route Catches now A non-database failure now gets
create(), webhook interception \Throwable Logged, and the write continues with the original request
logs(), object lookup \Exception 404 Object not found
vectorizeBatch() \Throwable Generic 500 Internal server error
getObjectVectorizationStats() \Throwable Generic 500 Internal server error
validate() \Exception 500 with the failure's message

Choices worth a look

  • External source failures still leave the routes. ObjectSourceErrorMiddleware answers DbalObjectSourceException and DbalWriteException with their own 4xx or 5xx status. A wider catch would have turned a source outage into Object not found, so logs(), validate() and both vectorization routes rethrow those two.
  • validate() stays on \Exception. Its answer holds the failure's message, and an Error's text carries internals. An Error stays with the server there.
  • New log lines. The vectorization routes and logs() logged nothing. Those failures used to reach Nextcloud's log by leaving the route, so catching them silently would lose them. A plain DoesNotExistException in logs() is not logged. Database failures on these routes now log too; their responses do not change.
  • The import is gone. Failed to read ZIP file content now throws RuntimeException, caught by the same \Exception block, so that answer does not change.

For a reviewer to decide

validate() now puts any \Exception message in the 500 body, where it used to do that for database failures only. It is the response that block was written to give, and the route needs a login, but a message can name internals. A generic answer like the vectorization routes would be a small follow-up.

The pins from #5856

testOtherFailuresLeaveTheRoutes recorded the old behaviour for three routes and is replaced by a test per route. The golden fixture gains only the new log lines on its failure cases; no recorded answer changed. testLogsThrowsWhenFindFails accepted either outcome, so it could not fail; it now asserts the 404. testCreateContinuesWhenWebhookFails runs a database failure, another exception and an Error.

Verified

  • Every unit test file naming ObjectsController: 1207 tests, 0 failures under pcov.
  • Capped mutants: 16 of 16 killed, at least one per block, plus each rethrow and each new log line.
  • phpcs, phpmd, phpstan clean on the file. Gate 122: 0 findings in 10 changed units, 26 inherited.
  • Not run on a live instance.

SourcesController also imports OCP\DB\Exception, but has no bare catch (Exception), so it was left alone.

Full suite

Full PHPUnit under pcov with --fail-on-risky through heavy.sh, on combined b193646ed (#5879, #5882, #5883 and #5887 on development 47f5021b9): 34640 tests, 1 failure, 34 risky. The failure is inherited: CalculationEvaluatorGoldenTest records a literal tomorrow for dateAdd bad date, so it goes red on any later day, and this tree touches no calculation file. The 34 risky are the 18 inherited plus 16 in ObjectsControllerGeoRoutesGoldenTest, also on development.

🤖 Generated with Claude Code

ObjectsController imported OCP\DB\Exception, so five catch (Exception) blocks
took database failures only and every other failure left the route.

- create(): a failing webhook interception now never breaks the write (Throwable).
- logs(): a failed lookup answers 404 (Exception), logged unless a plain miss.
- vectorizeBatch(), getObjectVectorizationStats(): any failure answers the
  generic 500 (Throwable), now logged, since the text never reaches the client.
- validate(): another Exception answers the 500 with its message. An Error stays
  with the server, so its text does not reach the client.

Failures of an external source still leave the routes, for
ObjectSourceErrorMiddleware to answer with their own status. Database failures
get the same responses as before. The import is gone, so the trap cannot return.

The pins from #5856 change with it: testOtherFailuresLeaveTheRoutes is replaced
and the golden gains the new log lines.

Assisted-by: ClaudeCode:claude-opus-5-5
Assisted-by: ClaudeCode:claude-opus-5-5
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/openregister @ 0886673

Check PHP Vue Security License Tests
lint ✅
phpcs ✅
phpmd ❌
psalm ❌
phpstan ❌
phpmetrics ✅
eslint ❌
stylelint ✅
build ✅
check-specs ✅
test-l10n ❌
test-l10n-parity ✅
format ✅
check-schema-l10n ✅
composer ✅ ✅ 165/165
npm ✅ ✅ 640/640
app:check-code ⏭️
info.xml ✅
REUSE ✅
lockfile sync ✅
PHPUnit ❌ 34608/34610 · 18 skipped
Newman ❌ 1628/1630
Playwright ⏭️ deferred: E2E runs locally and on the promotion path only. This pull request targets development, so the suite is asked once per promotion into beta and main rather than once per push per open pull request. Run it locally with npx playwright test, or from the Actions tab on a branch with no open pull request into development.
Hydra gates ❌

Quality workflow — 2026-11-06 08:34 UTC

Download the full PDF report from the workflow artifacts.

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