-
Notifications
You must be signed in to change notification settings - Fork 301
feat: update the error details response body content #289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe Changes
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
types.go
Outdated
| Value string `json:"value"` | ||
| Location string `json:"location"` | ||
| Issue string `json:"issue"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Verification correct
Verify the struct changes align with PayPal API documentation and assess breaking change impact.
The struct field modifications look syntactically correct, but this represents a significant breaking change:
Removed fields: Name and Message (as mentioned in AI summary)
Added fields: Value and Location
Repositioned: Issue field
Please verify this change matches the actual PayPal API documentation:
Additionally, search for existing usage of the removed fields:
🏁 Script executed:
#!/bin/bash
# Description: Search for usage of removed ErrorResponseDetail fields that may break
# Expected: Find code that accesses .Name or .Message fields that will need updating
echo "Searching for usage of ErrorResponseDetail.Name field:"
rg -A 3 -B 3 "\.Name" --type go
echo -e "\nSearching for usage of ErrorResponseDetail.Message field:"
rg -A 3 -B 3 "\.Message" --type go
echo -e "\nSearching for ErrorResponseDetail struct usage:"
rg -A 5 -B 2 "ErrorResponseDetail" --type goLength of output: 6612
🌐 Web query:
PayPal Orders API v2 error response details structure for 400 errors
💡 Result:
PayPal Orders API v2 – Error Response Structure for 400 Errors
When you interact with the PayPal Orders API v2 and your request is invalid, you will typically receive an HTTP 400 status code. This indicates a client-side error, such as malformed JSON, missing required fields, or data that does not comply with the schema expected by the API[2][6].
Structure of 400 Error Response
A typical 400 error response from the PayPal Orders API v2 is a JSON object with the following fields:
name: A short code or identifier for the error (e.g.,INVALID_REQUEST,VALIDATION_ERROR).message: A human-readable message describing the error.debug_id: A unique identifier for this error occurrence, useful for troubleshooting with PayPal support.details: (Optional) An array providing granular details about the validation failures, such as which fields were problematic.links: (Optional) An array of HATEOAS links with more information or documentation about the error[8][10].
Example Error Response
{
"name": "INVALID_REQUEST",
"message": "Request is not well-formed, syntactically incorrect, or violates schema.",
"debug_id": "bd5e1ff1bd5b6",
"details": [
{
"field": "/purchase_units/@reference_id=='1194780236'/items/0/category",
"value": "",
"issue": "INVALID_PARAMETER_VALUE",
"location": "body"
}
],
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-INVALID_PARAMETER_VALUE",
"rel": "information_link"
}
]
}[8][10]
Key Fields Explained
- name: The error type, such as
INVALID_REQUESTfor bad input, orVALIDATION_ERRORfor validation issues[10]. - message: Plain language description of the problem[8][10].
- debug_id: Allows PayPal support to trace the specific error event in their logs[8][10].
- details: Each item details an issue, pointing to the exact field (using JSON Pointer notation), the problematic value, the nature of the issue (e.g.,
INVALID_PARAMETER_VALUE,MISSING_REQUIRED_PARAMETER), and sometimes the location (typically "body")[8]. - links: May include documentation or help URLs for specific errors[8].
Common Causes and Details
- Malformed Request: The JSON is not properly structured or contains syntax errors.
- Missing Required Fields: A necessary property is missing from the request object.
- Incorrect Data Types: Provided data does not match the API schema (e.g., string when integer is expected).
- Schema Violations: Values break schema rules, such as unsupported currency codes or invalid country codes[6][8][9].
Additional Notes
- The error response structure is consistent for most validation and client errors (400 series), including business logic errors (such as mismatched totals)[5][8].
- If the
detailsarray is present, examine each item for the exact field and reason for failure—this is crucial for debugging[8].
References for Troubleshooting
For more examples and troubleshooting guidance, see PayPal's official documentation:
- [Orders v2 Error Reference][1]
- [API Error Handling Guide][4][5]
- [Understanding INVALID_REQUEST Errors][6]
Summary Table: Typical 400 Error Response Structure
| Field | Type | Description |
|---|---|---|
| name | string | Error type identifier (e.g., INVALID_REQUEST) |
| message | string | Human-readable error description |
| debug_id | string | Unique debugging identifier |
| details | array | (Optional) Array of objects with validation issues |
| links | array | (Optional) Array of objects with documentation/help URLs |
This structure helps developers identify exactly what went wrong in their request and where to start troubleshooting[8][10].
Citations:
- 1: https://developer.paypal.com/api/rest/reference/orders/v2/errors/
- 2: https://developer.paypal.com/api/rest/responses/
- 3: https://developer.paypal.com/docs/api/orders/v2/
- 4: https://developer.paypal.com/api/rest/integration/orders-api/troubleshooting/
- 5: https://developer.paypal.com/api/rest/integration/orders-api/errors/
- 6: https://developer.paypal.com/community/blog/invalid-request-error-paypal-rest-api/
- 7: https://developer.paysafe.com/en/api-docs/payments-api/add-payment-methods/paypal/error-codes-and-transaction-status/
- 8: https://www.paypal-community.com/t5/Sandbox-Environment/API-call-error-400-Request-is-not-well-formed-syntactically/td-p/3073998
- 9: https://developer.paypal.com/docs/api/payments/v2/
- 10: https://www.paypal-community.com/t5/REST-APIs/Response-code-400-Error-response/td-p/2327401
Verify the struct changes align with PayPal API documentation and assess breaking change impact.
The struct field modifications look syntactically correct, but this represents a significant breaking change:
Removed fields: Name and Message (as mentioned in AI summary)
Added fields: Value and Location
Repositioned: Issue field
Please verify this change matches the actual PayPal API documentation:
PayPal Orders API v2 error response details structure for 400 errors
Additionally, search for existing usage of the removed fields:
#!/bin/bash
# Description: Search for usage of removed ErrorResponseDetail fields that may break
# Expected: Find code that accesses .Name or .Message fields that will need updating
echo "Searching for usage of ErrorResponseDetail.Name field:"
rg -A 3 -B 3 "\.Name" --type go
echo -e "\nSearching for usage of ErrorResponseDetail.Message field:"
rg -A 3 -B 3 "\.Message" --type go
echo -e "\nSearching for ErrorResponseDetail struct usage:"
rg -A 5 -B 2 "ErrorResponseDetail" --type go🤖 Prompt for AI Agents
In types.go around lines 731 to 733, the struct fields for ErrorResponseDetail
have been changed by removing Name and Message, adding Value and Location, and
repositioning Issue. Verify these changes against the official PayPal Orders API
v2 error response documentation for 400 errors to ensure accuracy. Then, perform
a codebase search for any usage of the removed fields Name and Message to
identify and update all references accordingly to prevent breaking changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
unit_test.go (1)
149-152: Consider adding content to the links array for more comprehensive testing.The links array is currently empty, which is valid but may not provide comprehensive test coverage. Consider adding at least one link object to ensure the Links field unmarshaling works correctly, similar to
TestTypeErrorResponseOne."links": [ - + { + "href": "https://developer.paypal.com/docs/api/orders/v2/#error-TRACKING_NUMBER_ALREADY_EXIST", + "rel": "related", + "method": "GET" + } ]
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
unit_test.go(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
unit_test.go (1)
types.go (3)
ErrorResponse(739-746)Name(1231-1238)Details(718-726)
🔇 Additional comments (2)
unit_test.go (2)
138-154: JSON structure correctly updated to match new ErrorResponseDetail schema.The JSON response has been properly updated to reflect the new
ErrorResponseDetailstruct fields (value,location) while removing the old ones (name,message). The structure aligns with PayPal's Orders API v2 documentation as stated in the PR objectives.
165-167: Assertions correctly updated for new struct fields.The test assertions have been properly updated to validate the new
ErrorResponseDetailfields:
Issuefield verification retainedValuefield added to check the new tracking number valueDescriptionfield verification retained- Removed checks for obsolete
NameandMessagefields
|
Thank you @SpectatorNan can you also please move Links to |
I apologize, but I focused on the details and overlooked the links. |
plutov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @SpectatorNan
What does this PR do?
update the error details response body content
Any background context you want to provide?
details docs:
https://developer.paypal.com/docs/api/orders/v2/#orders_create!c=400&path=details/field&t=response
Summary by CodeRabbit