fix: return preflight simulation errors as 400 instead of 500#49
fix: return preflight simulation errors as 400 instead of 500#49
Conversation
PreflightError (e.g. "ERC20: transfer amount exceeds balance") was falling through to the catch-all arm in map_raindex_error and being returned as a 500 Internal Error with a generic message. Now it is explicitly matched and returned as a 400 Bad Request with the readable error message so callers know why their swap failed. Also export COMMIT_SHA automatically in the nix dev shell so local cargo builds no longer need the env var set manually. Add dev-config.toml and gitignore docs/book/ build output.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe changes introduce development configuration, update the Nix development shell, and extend error handling. A new dev configuration file is added with paths and rate limits, the shell environment is modified to include a COMMIT_SHA variable derived from Git HEAD, error handling for preflight validation failures is added to the swap route, and the gitignore is updated to exclude documentation build artifacts. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Motivation
When a swap calldata request fails due to a preflight simulation error (e.g. "ERC20: transfer amount exceeds balance"), the API returns a generic
500 Internal Server Errorwith "failed to generate calldata". This hides the actual cause from callers and makes it look like a server bug when it's really an on-chain condition the user can act on.Solution
RaindexError::PreflightErrorinmap_raindex_error()so it returns a400 Bad Requestwith the readable error message instead of falling through to the catch-all500 Internal Error.COMMIT_SHAautomatically in the nix dev shell (flake.nix) so local builds no longer require manually setting the env var.dev-config.tomlfor local development and gitignoredocs/book/build output.Checks
By submitting this for review, I'm confirming I've done the following:
Summary by CodeRabbit
Release Notes
Bug Fixes
Chores