JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

Should fail with original error

Open
#1,133 0 comments 0 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

In some cases original exceptions have important effects, for example I ran with issue that this fix is not working with jsonapi-resources "deallocate prepared statements if we fail inside a transaction"(https://github.com/rails/rails/pull/22170), so when you shallow error here you'd potentially breaks some other logic.

I think you should propagate original error, not just ActiveRecord::Rollback

Something like this should work, I think
https://github.com/cerebris/jsonapi-resources/blob/v0.9.0/lib/jsonapi/operation_dispatcher.rb#L30:
rollback(transactional) if results.has_errors? => fail results.original_error if results.has_errors? && transactional

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

Start with operation_dispatcher.rb around line 30 and acts_as_resource_controller.rb around line 100, then review the referenced transaction behavior in the linked Rails change. Confirm that a transactional operation propagates its original exception rather than only ActiveRecord::Rollback, while non-transactional behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.