JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

More Helpful Error Messages for Relationship Type Mismatches

Open
#807 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Enhancement
Dominant language
Ruby
Stars
2.3k
Forks
546
PR merge metrics
No merged PRs in 30d

Description

I encountered the following error today: "{"errors":[{"title":"Type Mismatch","detail":"category is not a valid type for this operation.","code":"116","status":"400"}]}". My Ingredient resources has a belongs-to relationship to Category. Eventually through Dan Gebhardt's help I came to realize that I should have been using the plural name of the resource in my request.

It'd be nice to have a more helpful error message when such an error occurs. Imagine my error message also included a list of valid types, e.g. "Valid types include 'categories', 'cars', 'sith-lords'." Perhaps this would only apply in dev mode, though it may not hurt in prod too.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue does not name a file, test, or entry point. Start by locating the error path that handles invalid relationship resource types and inspect related error-response tests. Done means the mismatch response identifies valid resource types, with the development-versus-production behavior resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
api, backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.