Skip to content
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

fix(schema)!: fixes and key restrictions based on indexer testing #21362

Merged
merged 5 commits into from
Aug 20, 2024

Conversation

aaronc
Copy link
Member

@aaronc aaronc commented Aug 19, 2024

Description

This code was pulled from #21186 after successful testing. I've split it into a separate PR to make that PR smaller.

The most notable changes are:

  • float32, float64 and JSON types cannot be used as object key fields because equality is not well defined
  • decimal and integer deterministic key string rendering was added in an exported schematesting.ObjectKeyString function
  • some errors with value and type generation were fixed to avoid generating invalid data

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a validation mechanism for key field types in the ObjectType, ensuring only valid types are accepted.
    • Added a new method to check if a kind is a valid key kind.
    • Implemented a new function for formatting object keys as strings for consistent storage.
  • Improvements

    • Enhanced error reporting for invalid key fields, providing clearer feedback.
    • Updated comments across various components for better clarity on validation rules.
    • Improved the handling of numeric and JSON types within schema updates.
    • Separated the generation logic for key and value fields, enhancing clarity and integrity.
    • Streamlined the object key formatting logic by centralizing it in a dedicated function.
  • Tests

    • Added new test cases to verify the validation of key fields against invalid types and to validate the output of the new key formatting function.
  • Documentation

    • Enhanced comments in the code for better understanding of changes and functionality.

Copy link
Contributor

coderabbitai bot commented Aug 19, 2024

Walkthrough

Walkthrough

The recent changes across the schema files enhance the handling of key fields and value comparisons, improve validation logic, and streamline object update mechanisms. A new method for validating key kinds was introduced, along with refined criteria to ensure data integrity. Additionally, updates include improved comments and expanded test cases, contributing to better documentation and increased test coverage.

Changes

Files Change Summary
schema/kind.go, schema/object_type.go, schema/object_type_test.go Enhanced handling of key kinds, added ValidKeyKind() function, and improved validation for key fields.
schema/testing/appdatasim/app_data.go, schema/testing/statesim/object_coll.go, schema/testing/statesim/object_coll_diff.go Refined key formatting and update handling, introducing new helper functions for clarity and consistency.
schema/testing/field.go, schema/testing/object.go Separation of key and value field generation logic; improved checks for duplicate names.
schema/testing/fmt.go, schema/testing/fmt_test.go Added functionality for formatting object keys, alongside a comprehensive test suite for validation.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Schema
    participant Validator
    participant ObjectGenerator

    User->>Schema: Request to create object
    Schema->>Validator: Validate key kind
    Validator-->>Schema: Key kind valid/invalid
    Schema->>ObjectGenerator: Generate object with valid keys
    ObjectGenerator-->>Schema: Return generated object
    Schema-->>User: Provide created object
Loading

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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@aaronc aaronc marked this pull request as ready for review August 19, 2024 17:43
@aaronc aaronc requested a review from a team as a code owner August 19, 2024 17:43
@aaronc aaronc changed the title fix(schema): fixes and key restrictions based on indexer testing fix(schema)!: fixes and key restrictions based on indexer testing Aug 19, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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)
schema/testing/appdatasim/testdata/app_sim_example_schema.txt (1)

100-100: Correct grammatical errors.

Use "an" instead of "a" before words starting with a vowel sound.

- "ThreeKeys","Key":["@(\u0001\u0001\tᛰᾚ𐺭a'ᵆᾭaa",16,817744173394],"Value":{"Value1":145},"Delete":false}
+ "ThreeKeys","Key":["@(\u0001\u0001\tᛰᾚ𐺭an'ᵆᾭaa",16,817744173394],"Value":{"Value1":145},"Delete":false}

- "ThreeKeys","Key":["@(\u0001\u0001\tᛰᾚ𐺭a'ᵆᾭaa",16,817744173394],"Value":-1,"Delete":false}
+ "ThreeKeys","Key":["@(\u0001\u0001\tᛰᾚ𐺭an'ᵆᾭaa",16,817744173394],"Value":-1,"Delete":false}

Also applies to: 157-157

Tools
LanguageTool

[misspelling] ~100-~100: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ..."ThreeKeys","Key":["@(\u0001\u0001\tᛰᾚ𐺭a'ᵆᾭaa",16,817744173394],"Value":{"Value1...

(EN_A_VS_AN)

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c286e6e and 776104c.

Files selected for processing (12)
  • schema/kind.go (3 hunks)
  • schema/object_type.go (2 hunks)
  • schema/object_type_test.go (1 hunks)
  • schema/testing/appdatasim/app_data.go (3 hunks)
  • schema/testing/appdatasim/testdata/app_sim_example_schema.txt (1 hunks)
  • schema/testing/appdatasim/testdata/diff_example.txt (1 hunks)
  • schema/testing/example_schema.go (1 hunks)
  • schema/testing/field.go (1 hunks)
  • schema/testing/module_schema.go (2 hunks)
  • schema/testing/object.go (3 hunks)
  • schema/testing/statesim/object_coll.go (5 hunks)
  • schema/testing/statesim/object_coll_diff.go (1 hunks)
Additional context used
Path-based instructions (10)
schema/testing/module_schema.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

schema/testing/statesim/object_coll_diff.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

schema/testing/example_schema.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

schema/object_type.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

schema/testing/object.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

schema/testing/field.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

schema/testing/statesim/object_coll.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

schema/testing/appdatasim/app_data.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

schema/object_type_test.go (2)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

schema/kind.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

LanguageTool
schema/testing/appdatasim/testdata/app_sim_example_schema.txt

[misspelling] ~100-~100: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ..."ThreeKeys","Key":["@(\u0001\u0001\tᛰᾚ𐺭a'ᵆᾭaa",16,817744173394],"Value":{"Value1...

(EN_A_VS_AN)


[misspelling] ~157-~157: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ..."ThreeKeys","Key":["@(\u0001\u0001\tᛰᾚ𐺭a'ᵆᾭaa",16,817744173394],"Value":-1,"Dele...

(EN_A_VS_AN)

Additional comments not posted (25)
schema/testing/module_schema.go (2)

46-50: Variable renaming from schema to sch is acceptable.

The change in variable name from schema to sch in MustNewModuleSchema enhances readability without affecting functionality.


32-32: Ensure function hasDuplicateTypeNames is correctly implemented and used.

The renaming from hasDuplicateNames to hasDuplicateTypeNames suggests a focus on type names. Verify that this function accurately checks for duplicate type names in both KeyFields and ValueFields.

Verification successful

Function hasDuplicateTypeNames is correctly implemented and used.

The function accurately checks for duplicate type names by iterating over fields and using a map to track seen type names, focusing on fields of EnumKind. The logic aligns with the intended functionality.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `hasDuplicateTypeNames` function.

# Test: Search for the function implementation and usage. Expect: Correct logic for checking duplicate type names.
ast-grep --lang go --pattern 'func hasDuplicateTypeNames($_, $_) bool { $$$ }'

Length of output: 772

schema/testing/statesim/object_coll_diff.go (1)

38-38: Ensure FormatObjectKey is correctly implemented and used.

The replacement of fmtObjectKey with FormatObjectKey suggests a move to a standardized method. Verify that FormatObjectKey is correctly implemented and used for formatting object keys.

Verification successful

FormatObjectKey is correctly implemented and used.

The FormatObjectKey function is implemented with a robust logic to handle different cases of key formatting and is consistently used throughout the codebase for its intended purpose of formatting object keys. No issues found.

  • Implementation in schema/testing/statesim/object_coll.go
  • Usage in schema/testing/statesim/object_coll.go, schema/testing/statesim/object_coll_diff.go, and schema/testing/appdatasim/app_data.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of `FormatObjectKey` function.

# Test: Search for the function implementation and usage. Expect: Correct logic for formatting object keys.
ast-grep --lang go --pattern 'func FormatObjectKey($_, $_) string { $$$ }'

Length of output: 1532


Script:

#!/bin/bash
# Description: Search for all usages of `FormatObjectKey` in the codebase to verify correct usage.
rg 'FormatObjectKey' -A 3

Length of output: 1919

schema/testing/appdatasim/testdata/diff_example.txt (1)

5-67: Verify intentional changes in expected vs. actual discrepancies.

The discrepancies in object collections suggest changes in underlying data handling. Ensure these changes are intentional and documented.

schema/testing/example_schema.go (1)

155-157: New check for valid key kinds enhances robustness.

The addition of a check to default invalid key kinds to Int32Kind in mkTestObjectType is a positive change. Ensure the logic is correctly implemented.

schema/object_type.go (2)

14-16: Clarification on key field constraints is beneficial.

The updated comments clarify constraints on key fields, enhancing documentation and understanding.


58-60: New validation logic for key kinds improves robustness.

The added validation logic ensures key fields have valid kinds, enhancing error reporting and robustness. Verify the implementation.

schema/testing/object.go (5)

10-12: Good separation of key and value field generation.

The introduction of keyFieldsGen and valueFieldsGen improves clarity by distinctly handling key and value fields. This change enhances the code's readability and maintainability.


30-37: Improved duplicate field name checks.

The use of hasDuplicateFieldNames for both key and value fields ensures robust validation against duplicate field names, enhancing schema integrity.


50-58: Clarification on duplicate field name detection.

The hasDuplicateFieldNames function effectively checks for duplicate field names, ensuring that schemas are correctly validated for uniqueness.


Line range hint 60-74: Refined duplicate type name checks.

The hasDuplicateTypeNames function now specifically checks for duplicate enum type names, which is crucial for maintaining schema consistency.


104-111: Enhanced key filtering in ObjectUpdateGen.

The filtering mechanism prevents updates from using keys already present in the state, which improves the integrity of the object updates.

schema/testing/field.go (1)

38-40: Introduction of KeyFieldGen enhances key field generation.

The new KeyFieldGen ensures that only non-nullable fields of valid key kinds are generated, which is essential for schema integrity.

schema/testing/statesim/object_coll.go (3)

52-52: Consistent key formatting with FormatObjectKey.

The use of FormatObjectKey ensures consistent key formatting across the codebase, which is crucial for maintaining data integrity.


123-123: Consistent key retrieval with FormatObjectKey.

The update to use FormatObjectKey in GetObject maintains consistency in key handling, which is important for reliable data retrieval.


Line range hint 137-175: Improved key formatting and value normalization.

The FormatObjectKey function provides deterministic key formatting, and the fmtValue function enhances value normalization by handling decimal and integer strings more accurately.

schema/testing/appdatasim/app_data.go (2)

Line range hint 95-110: Centralized key formatting with formatUpdateKey.

The introduction of formatUpdateKey centralizes the logic for key generation, improving clarity and reducing potential errors in update handling.


121-134: Robust update key formatting with formatUpdateKey.

The formatUpdateKey function enhances robustness by encapsulating key formatting logic, ensuring consistency and reducing duplication.

schema/object_type_test.go (1)

192-230: Enhanced test coverage for invalid key field types.

The additional test cases for float32, float64, and json key fields ensure that these invalid types are correctly flagged, enhancing validation robustness.

schema/kind.go (2)

82-83: Clarification on equality comparison is beneficial.

The added comments emphasize the importance of using numerical equality over string equality for IntegerStringKind and DecimalStringKind, which improves clarity.

Also applies to: 92-93


376-386: Addition of ValidKeyKind enhances key validation.

The new function ValidKeyKind correctly identifies valid key kinds, aligning with the PR's objective to restrict certain types as keys.

schema/testing/appdatasim/testdata/app_sim_example_schema.txt (4)

10-16: Schema updates align with PR objectives.

The changes to OnObjectUpdate entries, including new update types and modifications to existing values, align with the PR's objectives to enhance data representation and introduce new types.

Also applies to: 22-29, 32-37, 46-50, 57-60, 65-70, 79-82, 88-92, 96-101, 109-113, 115-120, 127-131, 134-140, 146-150


33-33: Removal of outdated updates is appropriate.

The removal of certain updates reflects a refinement in the schema, eliminating outdated or irrelevant data types.

Also applies to: 48-48, 53-53, 65-65, 69-69, 81-81, 98-98, 112-112, 122-122, 123-123, 131-131, 137-137


12-12: Structural changes enhance data handling.

The structural changes in OnObjectUpdate entries improve the schema's ability to handle more complex data scenarios.

Also applies to: 59-59, 73-73, 89-89, 96-96, 104-104, 113-113, 126-126, 128-128, 138-138, 149-149, 158-158


10-10: Verify changes in module names.

Ensure that the changes in module names do not affect processing or referencing in the application.

Also applies to: 57-57, 79-79, 96-96, 115-115, 138-138

Verification successful

Module Names Are Consistently Used

The module names "all_kinds" and "test_cases" are consistently referenced throughout the app_sim_example_schema.txt file. There are no discrepancies in their usage that would suggest any issues with processing or referencing within the application.

  • All instances of ModuleName with "all_kinds" and "test_cases" appear to be used correctly in context.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify changes in module names do not affect processing.

# Test: Search for module name usage. Expect: Consistent references.
rg --type text 'ModuleName":"all_kinds"' -A 2
rg --type text 'ModuleName":"test_cases"' -A 2

Length of output: 154


Script:

#!/bin/bash
# Description: Verify changes in module names do not affect processing.

# Test: Search for module name usage. Expect: Consistent references.
rg 'ModuleName":"all_kinds"' -A 2
rg 'ModuleName":"test_cases"' -A 2

Length of output: 61097

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 776104c and 2e38072.

Files selected for processing (1)
  • schema/testing/object.go (4 hunks)
Additional context used
Path-based instructions (1)
schema/testing/object.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (6)
schema/testing/object.go (6)

11-13: LGTM!

The keyFieldsGen variable correctly generates distinct key fields, ensuring uniqueness by name.


15-16: LGTM!

The valueFieldsGen variable correctly generates distinct value fields, ensuring uniqueness by name.


24-50: LGTM!

The ObjectTypeGen function correctly generates object types and ensures no duplicate field or type names exist.


51-59: LGTM!

The hasDuplicateFieldNames function efficiently checks for duplicate field names using a map.


Line range hint 61-74: LGTM!

The hasDuplicateTypeNames function correctly checks for duplicate type names among fields of kind EnumKind.


85-92: LGTM!

The ObjectUpdateGen function correctly filters out keys that already exist in the state, enhancing update integrity.

Copy link

Quality Gate Passed Quality Gate passed for 'Cosmos SDK - Schema Testing'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2e38072 and ebb6c31.

Files selected for processing (7)
  • schema/testing/appdatasim/app_data.go (4 hunks)
  • schema/testing/field.go (2 hunks)
  • schema/testing/fmt.go (1 hunks)
  • schema/testing/fmt_test.go (1 hunks)
  • schema/testing/object.go (3 hunks)
  • schema/testing/statesim/object_coll.go (3 hunks)
  • schema/testing/statesim/object_coll_diff.go (1 hunks)
Files skipped from review as they are similar to previous changes (4)
  • schema/testing/appdatasim/app_data.go
  • schema/testing/field.go
  • schema/testing/object.go
  • schema/testing/statesim/object_coll_diff.go
Additional context used
Path-based instructions (3)
schema/testing/fmt.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

schema/testing/fmt_test.go (2)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

schema/testing/statesim/object_coll.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (3)
schema/testing/fmt_test.go (1)

9-60: Test cases are comprehensive and well-structured.

The test cases provide sufficient coverage for the ObjectKeyString function and adhere to best practices.

schema/testing/statesim/object_coll.go (2)

51-51: Integration of ObjectKeyString in ApplyUpdate is correct.

The use of ObjectKeyString for key formatting in ApplyUpdate is appropriate and enhances consistency.


122-122: Integration of ObjectKeyString in GetObject is correct.

The use of ObjectKeyString for key retrieval in GetObject is appropriate and enhances consistency.

Comment on lines +14 to +35
func ObjectKeyString(objectType schema.ObjectType, key any) string {
keyFields := objectType.KeyFields
n := len(keyFields)
switch n {
case 0:
return ""
case 1:
valStr := fmtValue(keyFields[0].Kind, key)
return fmt.Sprintf("%s=%v", keyFields[0].Name, valStr)
default:
ks := key.([]interface{})
res := ""
for i := 0; i < n; i++ {
if i != 0 {
res += ", "
}
valStr := fmtValue(keyFields[i].Kind, ks[i])
res += fmt.Sprintf("%s=%v", keyFields[i].Name, valStr)
}
return res
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding type checks for key assertions.

In the default case, the function assumes key is a []interface{} without checking. This could lead to a panic if the assumption is incorrect. Consider adding a type check or error handling.

ks, ok := key.([]interface{})
if !ok {
  panic("expected key to be of type []interface{}")
}

Comment on lines +37 to +52
func fmtValue(kind schema.Kind, value any) string {
switch kind {
case schema.BytesKind, schema.AddressKind:
return fmt.Sprintf("0x%x", value)
case schema.DecimalStringKind, schema.IntegerStringKind:
// we need to normalize decimal & integer strings to remove leading & trailing zeros
d, _, err := apd.NewFromString(value.(string))
if err != nil {
panic(err)
}
r := &apd.Decimal{}
r, _ = r.Reduce(d)
return r.String()
default:
return fmt.Sprintf("%v", value)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace panic with error handling.

Using panic for error handling is not recommended in production code. Consider returning an error instead.

d, _, err := apd.NewFromString(value.(string))
if err != nil {
  return "", err
}

Update the function signature to return (string, error) and handle the error in the calling code.

@aaronc aaronc added this pull request to the merge queue Aug 20, 2024
Merged via the queue into main with commit 95dcf84 Aug 20, 2024
78 checks passed
@aaronc aaronc deleted the aaronc/schema-testing-fixes branch August 20, 2024 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants