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

Tfplugingen-openapi generate panic: runtime error: invalid memory address or nil pointer dereference #190

Open
1 task done
tofkamp opened this issue Aug 31, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@tofkamp
Copy link

tofkamp commented Aug 31, 2024

tfplugingen-openapi CLI version

tfplugingen-openapi module: v0.3.0

OpenAPI Spec File

It is 650Kb. I found this by the company Engenius https://liveapi-console-dev.s3-us-west-2.amazonaws.com/engenius_cloud/openapi.yaml

Generator Config

provider:
  name: engenius
resources:
  orgs:
    create:
      path: /orgs
      method: POST
    read:
      path: /orgs/{orgId}
      method: GET
    update:
      path: /orgs/{orgId}
      method: PATCH
    delete:
      path: /orgs/{orgId}
      method: DELETE
data_sources:
  orgs:
    read:
      path: /user/orgs
      method: GET

Expected Behavior

Make a code-spec file. It is just a very simple first try in order to make a terraform provider.
Not have a memory violation

Actual Behavior

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa0bf48]

goroutine 1 [running]:
github.com/pb33f/libopenapi/datamodel/high/base.(*DynamicValue[...]).IsA(...)
        /home/tjibbe/go/pkg/mod/github.com/pb33f/[email protected]/datamodel/high/base/dynamic_value.go:29
github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas.(*OASSchema).BuildCollectionDataSource(0xc0015648c0, {0xc000182098, 0x4}, {0xcbb430?, 0xc000ef0340?})
        /home/tjibbe/go/pkg/mod/github.com/hashicorp/[email protected]/internal/mapper/oas/collection.go:118 +0x48
github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper/oas.(*OASSchema).BuildDataSourceAttribute(0xc0015648c0, {0xc000182098, 0x4}, {0xcbb430, 0x8})
        /home/tjibbe/go/pkg/mod/github.com/hashicorp/[email protected]/internal/mapper/oas/attribute.go:121 +0xab
github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper.generateDataSourceSchema(0xc000c424d0, {0xc000182098, 0x4}, {0xc000f9cc30, {0x0, 0x0, 0x0}, {{0x0, 0x0, 0x0}, ...}})
        /home/tjibbe/go/pkg/mod/github.com/hashicorp/[email protected]/internal/mapper/datasource_mapper.go:91 +0x234
github.com/hashicorp/terraform-plugin-codegen-openapi/internal/mapper.dataSourceMapper.MapToIR({0xc0020daea0, {{{0xc000013f98, 0x8}, {0x0, 0x0}, {0x0, 0x0, 0x0}}, 0xc000176b10, 0xc000176bd0}}, ...)
        /home/tjibbe/go/pkg/mod/github.com/hashicorp/[email protected]/internal/mapper/datasource_mapper.go:48 +0x2f7
github.com/hashicorp/terraform-plugin-codegen-openapi/internal/cmd.generateProviderCodeSpec(0xc002569ba0, {0xdd65f8, 0xc0028bc100}, {{{0xc000013f98, 0x8}, {0x0, 0x0}, {0x0, 0x0, 0x0}}, ...})
        /home/tjibbe/go/pkg/mod/github.com/hashicorp/[email protected]/internal/cmd/generate.go:212 +0x525
github.com/hashicorp/terraform-plugin-codegen-openapi/internal/cmd.(*GenerateCommand).runInternal(0xc0000a1640, 0xc002569ba0)
        /home/tjibbe/go/pkg/mod/github.com/hashicorp/[email protected]/internal/cmd/generate.go:151 +0x514
github.com/hashicorp/terraform-plugin-codegen-openapi/internal/cmd.(*GenerateCommand).Run(0xc0000a1640, {0xc000022090, 0x5, 0x5})
        /home/tjibbe/go/pkg/mod/github.com/hashicorp/[email protected]/internal/cmd/generate.go:100 +0x2a5
github.com/hashicorp/cli.(*CLI).Run(0xc000095cc0)
        /home/tjibbe/go/pkg/mod/github.com/hashicorp/[email protected]/cli.go:265 +0x55f
main.runCLI({0xcc0136, 0x13}, {0xc0000287e0, 0x22}, {0xc000022080, 0x6, 0x6}, {0xdd1b20, 0xc00003e098}, {0xdd1b40, ...}, ...)
        /home/tjibbe/go/pkg/mod/github.com/hashicorp/[email protected]/cmd/tfplugingen-openapi/main.go:67 +0x348
main.main()
        /home/tjibbe/go/pkg/mod/github.com/hashicorp/[email protected]/cmd/tfplugingen-openapi/main.go:23 +0x12b

Additional Information

go version go1.23.0 linux/amd64

Description: Ubuntu 23.04
Release: 23.04
Codename: lunar

Converted the inputfile to json on swaggerhub, but that did not resolve anything.
You can see the api here https://liveapi-console-dev.s3-us-west-2.amazonaws.com/engenius_cloud/falcon.html
I imported it in swaggerhub, and it did not find any error, except the version number

Code of Conduct

  • I agree to follow this project's Code of Conduct
@tofkamp tofkamp added the bug Something isn't working label Aug 31, 2024
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

1 participant