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

Panic During Schema Rendering #285

Open
matteogastaldello opened this issue May 2, 2024 · 2 comments
Open

Panic During Schema Rendering #285

matteogastaldello opened this issue May 2, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@matteogastaldello
Copy link

matteogastaldello commented May 2, 2024

Hi!
I'm encountering a runtime panic due to an invalid memory address or nil pointer dereference when attempting to render a schema using the libopenapi library. This issue arises during the execution of the schema.Render() method, which results in a segmentation violation error.

These are the lines that throws the panic

	schema, err = bodySchema.BuildSchema()
	if err != nil {
		return fmt.Errorf("building schema for %s: %w", verb.Path, err), errors
	}
	schema.Properties.Set("authenticationRefs", base.CreateSchemaProxy(&base.Schema{
		Type:        []string{"object"},
		Description: "AuthenticationRefs represent the reference to a CR containing the authentication information. One authentication method must be set."}))
	schema.Required = append(schema.Required, []string{"authenticationRefs"}...)
	rend, err := schema.Render()
	if err != nil {
		return fmt.Errorf("rendering schema for %s: %w", verb.Path, err), errors
	}

This error occurs if schema.Required is not previously set in the oas specification used to build the model. Setting a "fake" required field in the oas specification file fix the behaviour.

Thanks for your help

@daveshanley daveshanley added the bug Something isn't working label May 2, 2024
@daveshanley
Copy link
Member

Hi,

What will really help me diagnose this problem is a blob of code I can copy and paste into my test-rig and debug the issue, the problem with snippets like this is that I have no idea how your source is structured or your base specification etc.

I really don't have the luxury of time to re-create this issue by reverse engineering the code you've provided. I really need something that will re-create the issue, that runs as a test or that will run as a copy paste job.

Thanks.

@matteogastaldello
Copy link
Author

Hi @daveshanley!

Here is the gist with all the information to reproduce the error: https://gist.github.com/matteogastaldello/823cdaf0127c2f2eaa92ddb574539825

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants