Skip to content

Handle fmu-settings migration errors consistently #440

Description

@GibranAlfa

The new schema migration support in fmu-settings raises MigrationError when stored config, mappings, or cache data cannot be migrated.

The API does not handle this error consistently today. MigrationError inherits from ValueError, so some routes already convert it to HTTP 422 through broad ValueError handling. Other routes can return an unhandled HTTP 500.

For example, opening a project currently catches it as a generic ValueError and reports the project as corrupt. The user-config route does not catch it.

Catching the error in each route would also miss errors raised while FastAPI resolves dependencies.

Proposed solution

Add a central FastAPI exception handler for MigrationError.

The handler should:

  • Return a consistent HTTP status and response body. HTTP 422 matches the current handling of invalid stored resource data.
  • Log the original error with enough detail for troubleshooting.
  • Give the GUI a stable error response that it can show to the user.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions