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

Make proto object verification give more descriptive error messages #1733

Merged
merged 7 commits into from
May 10, 2024

Conversation

Ekrekr
Copy link
Contributor

@Ekrekr Ekrekr commented May 9, 2024

Given that we can't do proper type validation due to ProtobufJS, this is the next best thing that I can think of.

@Ekrekr Ekrekr requested a review from BenBirt May 9, 2024 14:35
Comment on lines 32 to 33
suggestReportToDataformTeam: boolean = false,
showDocsLink: boolean = true
Copy link
Collaborator

Choose a reason for hiding this comment

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

give me an Options type so that these can be named and therefore readable at the callsite

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good shout

@Ekrekr Ekrekr requested a review from BenBirt May 10, 2024 08:36
@@ -24,7 +28,8 @@ export interface IProtoClass<IProto, Proto> {
// meaning that the type of fields cannot be verified; an int can be confused with a string.
export function verifyObjectMatchesProto<Proto>(
protoType: IProtoClass<any, Proto>,
object: object
object: object,
options?: { suggestReportToDataformTeam?: boolean; showDocsLink?: boolean }
Copy link
Collaborator

Choose a reason for hiding this comment

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

sorry, now I see that it looks like these options are effectively an enumeration - it essentially never makes sense for them both to be true; because suggestReportToDataformTeam always takes precedence.

I'd suggest:

errorBehaviour?: enum ErrorBehaviour { SUGGEST_REPORTING_TO_DATAFORM_TEAM, SHOW_DOCS_LINK }

@Ekrekr Ekrekr merged commit 9f57308 into main May 10, 2024
2 of 3 checks passed
@Ekrekr Ekrekr deleted the verify-object-match-closer-to-excess-properties-check branch May 10, 2024 09:04
moker-spaghetti pushed a commit to moker-spaghetti/dataform that referenced this pull request May 26, 2024
…ataform-co#1733)

* Make proto object verification give better details

* Fix error messages

* Tidy

* Add proto type URL to docs URL

* Update options to be object based

* Update to use enum for error behaviour
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants