When attempting to fetch a field that is not marked as public? true, a confusing error is generated.
To Reproduce
The Tunez.Music.Artist resource:
json_api do
type "artist"
routes do
base "/artists"
get :read
end
end
attributes do
uuid_primary_key :id
attribute :name, :string do
allow_nil? false
public? false # <--- fetching this field
end
end
Describe the bug
When attempting to fetch a field that is not marked as
public? true
, a confusing error is generated.To Reproduce
The
Tunez.Music.Artist
resource:The request:
http://localhost:4000/api/artists/4fad50ae-9f07-49c1-a04a-560477a5d47d?fields=name
The error:
(The warning is a Elixir 1.17 thing I think)
Expected behavior
The user should get back an error that they've requested something invalid.
When you submit a create request with invalid attributes, you get back an error like:
Something similar maybe?
The JSON:API spec is not clear on what should be returned.
Runtime