Skip to content

Serializer doesn't skip NotLoaded attributes (from select: [...] in prepare) #165

@flowerornament

Description

@flowerornament

Code of Conduct

  • I agree to follow this project's Code of Conduct

AI Policy

  • I agree to follow this project's AI Policy. AI was used to help draft this issue.

Versions

ash_ai 0.5.0, ash 3.5.7

Issue

Using prepare build(select: [...]) in an action causes the serializer to crash when serializing records with %Ash.NotLoaded{} attribute values.

(FunctionClauseError) no function clause matching in Decimal.to_string/2

Cause

The serializer skips NotLoaded for relationships, calculations, and aggregates, but not for attributes.

Fix

Add the same check for attributes after line 148:

match?(%Ash.Resource.Attribute{}, field) &&
    match?(%Ash.NotLoaded{}, Map.get(record, field.name)) ->
  acc

Metadata

Metadata

Assignees

No one assigned

    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