Skip to content

[explorer/rest] fix: fail startup on Symbol database initialization errors and return 503 on runtime failures - #2581

Draft
daoka wants to merge 1 commit into
explorer/backend/rest-receiptsfrom
explorer/backend/symbol-rest-db-injection
Draft

daoka wants to merge 1 commit into
explorer/backend/rest-receiptsfrom
explorer/backend/symbol-rest-db-injection

Conversation

@daoka

@daoka daoka commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

What is the current behavior?

SymbolRestFacade creates its own database and catches initialization errors, allowing the application to start without a usable database. Block detail requests can then return 404 despite the database being unavailable.

This PR builds on #2580 and targets explorer/backend/rest-receipts.

What's the issue?

Database initialization failures are hidden behind a running application, and unavailable data can be confused with a missing resource. Database construction and cleanup also lack a clear application-level owner.

How have you changed the behavior?

  • Create SymbolDatabase during application setup and inject it into SymbolRestFacade.
  • Fail application creation when database initialization fails. A connected but unsynced database still permits startup and is reported through Health.
  • Close the pool on setup failure, preserving the original exception when ordinary cleanup fails.
  • Keep the pool available across requests and register application finalization cleanup. Add idempotent close and context manager support.
  • Remove DB-absent facade states. Preserve 400 for invalid input and 404 for missing resources in readable data, while returning 503 for database read failures or unavailable synchronization state.

Startup compatibility changes: deployments that previously started without a database now fail during application creation. HTTP paths and response schemas are unchanged.

@daoka
daoka added this pull request to stack #2582 September 18, 2026 05:47
@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.25%. Comparing base (eb8ed00) to head (658b7f6).

Additional details and impacted files

Impacted file tree graph

@@                        Coverage Diff                         @@
##           explorer/backend/rest-receipts    #2581      +/-   ##
==================================================================
- Coverage                           97.43%   97.25%   -0.18%     
==================================================================
  Files                                 368      359       -9     
  Lines                               27148    25514    -1634     
  Branches                              251      251              
==================================================================
- Hits                                26451    24814    -1637     
- Misses                                690      693       +3     
  Partials                                7        7              
Flag Coverage Δ
explorer-puller ?
explorer-rest 99.80% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
explorer/rest/rest/__init__.py 100.00% <100.00%> (ø)
explorer/rest/rest/db/SymbolDatabase.py 100.00% <100.00%> (ø)
explorer/rest/rest/facade/SymbolRestFacade.py 100.00% <100.00%> (ø)
explorer/rest/rest/routes/symbol.py 100.00% <100.00%> (ø)

... and 43 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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