-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
🔥 Feature: Enhance CheckConstraint method for improved error handling #3356
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThis pull request refines constraint validation and error handling in the Changes
Sequence Diagram(s)sequenceDiagram
participant Caller
participant CheckConstraint
Caller->>CheckConstraint: Call CheckConstraint(param)
CheckConstraint->>CheckConstraint: Check for custom constraints
alt Custom constraint found
CheckConstraint-->>Caller: Return result
else No custom constraint
CheckConstraint->>CheckConstraint: Perform data conversions (int, bool, float, UUID, date)
alt Conversion error occurs
CheckConstraint-->>Caller: Return false
else Conversions valid
CheckConstraint->>CheckConstraint: Validate required constraint data and types
CheckConstraint-->>Caller: Return true
end
end
sequenceDiagram
participant Caller
participant FromContext
Caller->>FromContext: Call FromContext(context)
FromContext->>FromContext: Check if context is context.Context
alt context.Context match
FromContext-->>Caller: Return request ID
else
FromContext->>FromContext: Evaluate if context is fiber.Ctx (moved to last)
alt fiber.Ctx match
FromContext-->>Caller: Return request ID
else
FromContext-->>Caller: Log error and return empty string
end
end
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
Note 🎁 Summarized by CodeRabbit FreeYour organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 (
|
cool interesting |
var num int | ||
// First check if there's a custom constraint with the same name | ||
// This allows custom constraints to override built-in constraints | ||
for _, cc := range c.customConstraints { |
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.
Can you update the documentation about the behavior
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.
No problem, but Where in the docs should I explain this change?
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.
No problem, but Where in the docs should I explain this change?
You can add a note to https://docs.gofiber.io/next/guide/routing#custom-constraint
@JIeJaitt pls check the tests |
…and improve error handling
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3356 +/- ##
==========================================
- Coverage 83.73% 83.66% -0.08%
==========================================
Files 118 118
Lines 11728 11739 +11
==========================================
Hits 9821 9821
- Misses 1481 1489 +8
- Partials 426 429 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…benchmark test cases for clarity
…nd clean up CheckConstraint method in path.go
Description
Functions can now override custom constraint configurations and gofiber's built-in constraint configurations
close #3352