Repository navigation
feat(api): improve request handling and validation - #154
halibobo1205 wants to merge 4 commits into
Conversation
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
CodeAnt Nitpicks2 code suggestions1. The address is a 21-byte array here, but this log reports 42 as the required byte length, misleading anyone diagnosing invalid addresses.Incorrect variable usage · 2.
|
CodeAnt PR Risk: Low Risk
Assessed commit: |
05a422e to
f17a200
Compare
waynercheung
left a comment
There was a problem hiding this comment.
[SHOULD] Please document the concrete client-visible changes under Compatibility:
- JsonFormat enforces a 100,000-token budget per parsed document, including the ABI strings parsed by
deploycontractand JSON-RPCbuildTransaction. - Form-encoded bodies have a fixed 1,000-entry limit, including repeated keys.
- Multi-contract requests are rejected earlier. Some HTTP arrays containing a valid contract and an unparseable or untyped contract previously had the latter silently dropped. Rejected multi-contract sign-weight/approval replies omit
transaction. When rejection happens inpackTransaction, HTTPbroadcasttransactionreturns an emptytxid. - gRPC
createCommonTransactionnow returnsCONTRACT_VALIDATE_ERRORfor zero or multiple contracts, instead of failing on an empty list or using only the first contract. Wallet.broadcastTransactionchecks the contract count before the expiration check and beforeManager's cryptographic signature/permission validation, which can change error precedence. Its existing signature-length check still runs first.
I verified f17a200 locally with JDK 17: all 176 selected tests and framework Checkstyle pass. The build, coverage, style and smoke checks also pass on CI; submit-gradle fails because of its own JDK setup. The consensus validation rules and Manager's existing error message are unchanged, so no hard fork is required.
[NIT] DecodeUtil.java:21 reports 42 as the expected byte length; please log ADDRESS_SIZE / 2 (21 bytes). If the shielded servlet re-wrap stays, a short comment explaining that clientMessage matches the exact exception class would help.
| int max = ContextHandler.DEFAULT_MAX_FORM_KEYS; | ||
| int pairs = 1; | ||
| for (int i = 0; i < form.length(); i++) { | ||
| if (form.charAt(i) == '&' && ++pairs > max) { |
There was a problem hiding this comment.
[SHOULD] This counts every &, including empty segments that UrlEncoded.decodeUtf8To ignores. For example, 1,000 k=v entries followed by a trailing & decode to exactly 1,000 parameters but are rejected here. Please count only non-empty segments (still counting repeated keys), and add tests for leading, trailing and consecutive &.
| } | ||
|
|
||
| @Test | ||
| public void testServletsReportErrorWhenTransactionCannotBeParsed() throws Exception { |
There was a problem hiding this comment.
[DISCUSS] This test keeps the existing internal server error response when packTransaction returns null after a ParseException. Is keeping that response intentional for compatibility? If not, returning the parse error would avoid the null dereference in the servlets and give a clear validation error. This behavior predates the PR, so a follow-up is fine.
User description
Summary
Compatibility
Some previously accepted inputs may now be rejected. Earlier validation may change error precedence and returned fields, using endpoint-specific error responses.
Block processing, P2P and consensus behavior remain unchanged apart from address-validation logging.
CodeAnt-AI Description
Limit oversized API inputs and reject transactions with multiple contracts
What Changed
Impact
✅ Bounded parsing for oversized JSON requests✅ Rejected forms above the parameter limit✅ Clear validation errors for multi-contract transactions💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.