Skip to content

fix: Error messages for relations#349

Open
mesemus wants to merge 1 commit into
inveniosoftware:masterfrom
oarepo:feat-bad-relation-id-errors
Open

fix: Error messages for relations#349
mesemus wants to merge 1 commit into
inveniosoftware:masterfrom
oarepo:feat-bad-relation-id-errors

Conversation

@mesemus

@mesemus mesemus commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Description

There are two issues with how errors in relation fields (e.g., references to vocabularies) are handled in RDM records.

  • Error messages do not clearly indicate where the error occurred and what the error was.
  • These errors behave significantly differently from other validation errors. Normally, validation is performed at the service level using the marshmallow library. This allows even invalid drafts to be saved: incorrect fields are omitted from the draft and validation messages are returned in the errors field of the response.

Relation errors, however, are handled later during record commit. As a result, they raise an exception, the draft is not saved, and the response is serialized differently.

This PR addresses only the first issue. The second is architectural in nature, and resolving it would require a larger change that cannot realistically be completed in time for v14.

Problem and solution

Previously, relation validation errors used generic messages such as "Invalid field value", which made debugging difficult, especially in complex record structures with nested relations.

This change replaces those generic messages with more specific ones that include:

  • the invalid value
  • the field path where the error occurred

This makes it significantly easier to identify and resolve relation validation issues during development and debugging.

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Frontend

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

@mesemus mesemus added this to v14 Mar 16, 2026
@mesemus mesemus moved this to Triage in v14 Mar 16, 2026
* Replaced "Invalid field value" error message with
  a specific message, for example,
  "Invalid relation value {value!r} for field {self.key!r}."
* Updated tests
@mesemus
mesemus force-pushed the feat-bad-relation-id-errors branch from 3f5cc7b to 2f6bca5 Compare June 5, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant