Skip to content

Preserve embedded resource constraint errors - #2789

Open
BrendanWillis wants to merge 1 commit into
ash-project:mainfrom
BrendanWillis:issue-2331-embedded-resource-errors
Open

Preserve embedded resource constraint errors#2789
BrendanWillis wants to merge 1 commit into
ash-project:mainfrom
BrendanWillis:issue-2331-embedded-resource-errors

Conversation

@BrendanWillis

Copy link
Copy Markdown
Contributor

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

Preserves detailed validation errors when invalid values are found in embedded resources.

Previously, an embedded value could fail during dumping and lose useful constraint information. This caused the final error to have less detail than expected.

Changes

  • Reapply attribute constraints when dumping an embedded value fails.
  • Preserve detailed validation information when a constraint error is available.
  • Convert supported keyword error inputs into structured Ash errors.
  • Preserve the field, embedded path, invalid value, and constraint details.
  • Add regression tests for embedded-resource errors and keyword error normalization.

Comment thread lib/ash/error/error.ex
defp normalize_error_input(other, _opts), do: other

defp supported_error_keyword?(keyword) do
Enum.any?([:field, :fields, :message, :path, :index, :value, :private_vars], fn key ->

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a bit of a code smell, us having to detect a special kind of keyword list. In general I think this should be detected in the code for embedded types and handled at the source of these errors.

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