-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add defaults to ticket custom fields #207
Conversation
WalkthroughThe updates enhance the validation and retrieval processes for ticket custom fields, focusing on the addition of default values and improved error handling. Key changes include enhanced validation logic for Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant TicketService
participant ValidationModule
participant Database
User->>TicketService: Request Ticket
TicketService->>ValidationModule: Validate Ticket Fields
ValidationModule->>Database: Check Annotations and Default Values
Database-->>ValidationModule: Return Validation Results
ValidationModule-->>TicketService: Return Validation Status
TicketService-->>User: Respond with Ticket Data
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 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 as PR comments)
Additionally, you can add 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.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (1)
pb/c1/connector/v2/ticket.pb.go
is excluded by!**/*.pb.go
Files selected for processing (3)
- pb/c1/connector/v2/ticket.pb.validate.go (6 hunks)
- pkg/types/ticket/custom_fields.go (9 hunks)
- proto/c1/connector/v2/ticket.proto (2 hunks)
Additional context used
golangci-lint
pkg/types/ticket/custom_fields.go
320-320: error is not nil (line 318) but it returns nil
(nilerr)
GitHub Check: go-lint
pkg/types/ticket/custom_fields.go
[failure] 320-320:
error is not nil (line 318) but it returns nil (nilerr)
Additional comments not posted (16)
proto/c1/connector/v2/ticket.proto (8)
41-41
: Addition of annotations is appropriate.The addition of
repeated google.protobuf.Any annotations
enhances the flexibility of theTicketCustomField
message by allowing for additional metadata.
46-46
: Addition of default_value is beneficial.The
string default_value
field inTicketCustomFieldStringValue
provides a useful fallback mechanism for default values.
51-51
: Support for multiple default values is appropriate.The
repeated string default_values
field inTicketCustomFieldStringValues
aligns with the message's purpose of handling multiple values.
60-60
: Addition of default_value is useful.The
google.protobuf.Timestamp default_value
field inTicketCustomFieldTimestampValue
ensures that a default timestamp is available.
66-66
: Default value for pickable strings is beneficial.The
string default_value
field inTicketCustomFieldPickStringValue
enhances usability by providing a default option.
72-72
: Support for multiple default options is appropriate.The
repeated string default_values
field inTicketCustomFieldPickMultipleStringValues
aligns with the message's purpose of handling multiple selectable values.
78-78
: Default object value is beneficial.The
TicketCustomFieldObjectValue default_value
field inTicketCustomFieldPickObjectValue
ensures a default object is available.
84-84
: Support for multiple default object values is appropriate.The
repeated TicketCustomFieldObjectValue default_values
field inTicketCustomFieldPickMultipleObjectValues
aligns with the message's purpose of handling multiple selectable objects.pkg/types/ticket/custom_fields.go (3)
215-218
: Enhanced handling of empty values is robust.The added checks for empty string and slice values in
GetCustomFieldValue
improve robustness by ensuring empty values are explicitly handled.Also applies to: 222-226, 235-239, 242-246, 252-256
263-315
: Addition of GetDefaultCustomFieldValue is valuable.The
GetDefaultCustomFieldValue
function provides a fallback mechanism for default values, enhancing the existing logic.
317-326
: GetCustomFieldValueOrDefault simplifies value retrieval.The
GetCustomFieldValueOrDefault
function streamlines the logic by combining the retrieval of actual and default values.Tools
golangci-lint
320-320: error is not nil (line 318) but it returns nil
(nilerr)
GitHub Check: go-lint
[failure] 320-320:
error is not nil (line 318) but it returns nil (nilerr)pb/c1/connector/v2/ticket.pb.validate.go (5)
283-315
: Annotations validation logic is consistent and well-implemented.The validation logic for the
Annotations
field follows the established pattern, ensuring robust error handling.
1095-1123
: DefaultValue validation logic is consistent and well-implemented.The validation logic for the
DefaultValue
field inTicketCustomFieldTimestampValue
is consistent with the established pattern, ensuring robust error handling.
1506-1534
: DefaultValue validation logic is consistent and well-implemented.The validation logic for the
DefaultValue
field inTicketCustomFieldPickObjectValue
follows the established pattern, ensuring robust error handling.
1709-1742
: DefaultValues validation logic is consistent and well-implemented.The validation logic for the
DefaultValues
field inTicketCustomFieldPickMultipleObjectValues
follows the established pattern, ensuring robust error handling.
754-755
: Verify ifDefaultValue
requires validation.There are no validation rules for the
DefaultValue
field inTicketCustomFieldStringValue
. Ensure this is intentional and correct.
pkg/types/ticket/custom_fields.go
Outdated
func GetCustomFieldValueOrDefault(field *v2.TicketCustomField) (interface{}, error) { | ||
v, err := GetCustomFieldValue(field) | ||
if err != nil { | ||
return nil, nil |
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.
Fix error handling in GetCustomFieldValueOrDefault.
The function should return the error instead of nil
when an error occurs.
- return nil, nil
+ return nil, err
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
return nil, nil | |
return nil, err |
Tools
golangci-lint
320-320: error is not nil (line 318) but it returns nil
(nilerr)
GitHub Check: go-lint
[failure] 320-320:
error is not nil (line 318) but it returns nil (nilerr)
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
Outside diff range, codebase verification and nitpick comments (1)
pkg/types/ticket/custom_fields.go (1)
Line range hint
215-260
:
Document the behavior of returningnil
for empty values.The function returns
nil
for empty string and slice values. Consider adding documentation or comments to clarify this behavior, as it might not be suitable for all use cases.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- pkg/types/ticket/custom_fields.go (9 hunks)
Additional comments not posted (3)
pkg/types/ticket/custom_fields.go (3)
263-314
: LGTM!The
GetDefaultCustomFieldValue
function is well-implemented and aligns with the PR objectives by providing a fallback mechanism for default values.
317-326
: LGTM!The
GetCustomFieldValueOrDefault
function effectively combines value retrieval and default handling, enhancing robustness and flexibility.
Line range hint
390-594
:
LGTM!The updates to the
ValidateTicket
function ensure comprehensive validation by considering default values for required fields.
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.
Thank you. These default values are defined in the connectors yes?
|
Summary by CodeRabbit
New Features
Annotations
andDefaultValue
.Bug Fixes