Skip to content

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

@tofkamp

Description

@tofkamp

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions