Skip to content

Support for the Error groups in speccheck -- Extended open-rpc specs sample implementation#1

Merged
simsonraj merged 4 commits intomainfrom
error_groups_extension
May 10, 2025
Merged

Support for the Error groups in speccheck -- Extended open-rpc specs sample implementation#1
simsonraj merged 4 commits intomainfrom
error_groups_extension

Conversation

@simsonraj
Copy link
Copy Markdown
Owner

@simsonraj simsonraj commented Apr 20, 2025

Notes:

To Run:

Result:

Currently only warns, but continues, need to update once the Proposal is ironed out
image

)

// ErrorObject represents a single error in an error group
type ErrorObject struct {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think you might need to have an ErrorObjectOrRef as well as ErrorGroupOrRef.
for referennce for error object:
https://github.com/open-rpc/meta-schema/blob/master/openrpc_document.go#L467

this would then account for

x-error-groups: [ [{"$ref": "#/GasError1"}, {"$ref":"#/BlockError2"}], [{ code: 9999, message: "foobar"}], {"$ref":"#/AllUndefinedErrors} ]

where AllUndefinedErrors is of the type ErrorGroup

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Follow up comment here is that it looks like you want to throw on discovering refs, which makes sense.

}

func readSpec(path string) (*openrpc.OpenrpcDocument, error) {
func readSpec(path string) (*ExtendedOpenrpcDocument, error) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For the spec or this reading of the spec, I'm not sure if you'll have a dereferencer step already on the outside, that would make this easier as you wouldn't need to figure out how to resolve the json pointers, and so the ref types essentially wouldn't need to be specified.

It would just be a matter of general correctness, that you could then throw an error on, if someone passes you a ref vs the object, in the additional places. It might be nice to have those checks on the deserialiization like you have for the methodobject

Overall I think this makes sense

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Yea the spec should be fully de-referenced before passing on to the speccheck by this https://github.com/simsonraj/execution-apis/blob/error_groups/scripts/build.js#L145

I have also added additional validations, as you mentioned in the earlier comments

@simsonraj simsonraj changed the title support for the error groups in speccheck Support for the Error groups in speccheck -- Extended open-rpc specs sample implementation Apr 27, 2025
@simsonraj simsonraj merged commit 5750bb0 into main May 10, 2025
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.

2 participants