refactor!: refine /transaction
route response
#5395
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
This PR updates the HTTP response codes returned by Iroha when handling transactions, making them more consistent and expressive for different failure modes. Currently, the API:
200 OK
when a transaction is accepted, with no response body.400 Bad Request
for a wide variety of issues.500 Internal Server Error
when the queue is full.Problem
This approach lacks granularity and makes it hard for clients to reliably interpret what went wrong, especially in automated systems. It also does not follow common REST conventions.
Fixes #5391
Solution
This PR introduces the following improvements:
202 Accepted
when a transaction is successfully accepted into the pipeline (instead of200
).400 Bad Request
for cases like:401 Unauthorized
when signature verification fails.403 Forbidden
when the transaction is signed by the genesis account.503 Service Unavailable
when the transaction queue is full.Migration Guide (optional)
Breaking Change:
200 OK
upon transaction acceptance will now receive202 Accepted
. This should be updated in client-side logic.401
,403
,503
.Review notes (optional)
IntoResponse
, primarily matching error types.AcceptTransactionFail
andPushIntoQueue
for accurate status mapping.Checklist
CONTRIBUTING.md
.