-
-
Notifications
You must be signed in to change notification settings - Fork 1k
fix github_discussions.tsx file bug #4582
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
✅ Deploy Preview for asyncapi-website ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.
|
We require all PRs to follow Conventional Commits specification. |
WalkthroughThis update enhances the GitHub Discussions Netlify function with robust error handling, field validation, and parameterized GraphQL mutations. Error responses are now properly wrapped in a JSON body property to comply with Netlify Function response structure, addressing a bug where errors were malformed. Changes
Sequence DiagramsequenceDiagram
participant Client
participant Function as github_discussions Function
participant GraphQL as GitHub GraphQL API
Client->>Function: POST with event body
rect rgb(200, 220, 255)
Note over Function: Parse & Validate
Function->>Function: try/catch JSON.parse(event.body)
alt Parse succeeds
Function->>Function: Validate title & feedback present
alt Validation fails
Function-->>Client: 400 {body: {message: "Missing required fields"}}
end
else Parse fails
Function-->>Client: 400 {body: {message: "Invalid JSON"}}
end
end
rect rgb(200, 255, 220)
Note over Function,GraphQL: GraphQL Mutation (Parameterized)
Function->>GraphQL: Mutation with variables<br/>($repositoryId, $categoryId, $title, $body)
alt API succeeds
GraphQL-->>Function: Discussion created
Function-->>Client: 200 {body: {url, message}}
else API fails
GraphQL-->>Function: Error response
Function-->>Client: 500 {body: {message: "API error"}}
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)📓 Common learnings🧬 Code graph analysis (1)netlify/functions/github_discussions.ts (1)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
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 |
|
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-4582--asyncapi-website.netlify.app/ |
Description
This PR fixes the issues in the
netlify/functions/github_discussions.tsfunction related to error handling, input validation, and GraphQL query security.✅ Fixes Applied:
Fixed the Error Response Format Bug:
messageproperty in the return statement with a properly formattedbodyproperty containing JSON stringified content.Fixed GraphQL Injection Vulnerability:
Added Input Validation:
titleandfeedback.400,422,500) based on validation or runtime errors.Improved Error Handling:
{ statusCode, body }structure.Result
Related issue(s)
Fixes #4577
Example Test Results
401with error message400with validation error200with discussion data500with detailed messageNotes
netlify dev) and verified in both success and error states.Summary by CodeRabbit
Release Notes