Closed jlpedrosa closed 2 months ago
Hi @jlpedrosa 👋 Thank you for raising this and sorry you ran into trouble here.
I just tried the provided TrueNAS OpenAPI specification with the latest terraform-plugin-codegen-openapi on the main
branch and it appears that the panics are now proper errors, e.g.
{"time":"2024-04-25T10:55:25.274613-04:00","level":"ERROR","msg":"error building path item: schema build failed: reference '#components/schemas/return_schema_of_core_debug_mode_enabled' cannot be found at line 71, col 18"}
{"time":"2024-04-25T10:55:25.275-04:00","level":"ERROR","msg":"error building path item: schema build failed: reference '#components/schemas/return_schema_of_core_get_jobs' cannot be found at line 138, col 18"}
{"time":"2024-04-25T10:55:25.276322-04:00","level":"ERROR","msg":"error building path item: schema build failed: reference '#components/schemas/return_schema_of_core_sessions' cannot be found at line 342, col 18"}
... etc ...
I'm guessing the panic versus error difference is some bug fixes in the underlying OpenAPI handling library that this tooling uses. I will ask the maintaining team if they believe we should cut a bug fix release of terraform-plugin-codegen-openapi to at least make these sorts of situations more clear for everyone. I would treat that sort of bug fix release as closing this issue from the standpoint that the tooling would no longer unexpectedly panic in this situation and instead would be raising actual errors for troubleshooting.
As for the actual errors themselves, I believe the OpenAPI specification parsing is complaining because some of those references are #components/schemas/...
instead of #/components/schemas/...
(note the lack of beginning /
). You may want to double check if there is an updated OpenAPI specification file that resolves that sort of issue, or if that specification is seen as valid, we can raise a bug fix or feature request with the OpenAPI handling library.
Hi again 👋 After further testing, it appears replacing the #components/schemas/...
references with #/components/schemas/...
is what will prevent the panic from occurring in my environment. Having the OpenAPI specification be fully valid is a requirement of this tool, so I'm not sure if there is much else we can do in this tooling since we are quite dependent on the underlying OpenAPI parsing library behaviors when it encounters all the original errors but still tries to continue processing the specification to the point of it raising its own panic. It seems like the next best step might be raising an issue in https://github.com/pb33f/libopenapi/issues to potentially do something different to prevent the panic its raising.
Hi @bflad Thanks! I tracked down the issue with the provider with the specification and indeed they are working on a fix! thanks!
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
tfplugingen-openapi CLI version
tfplugingen-openapi module: v0.3.0
OpenAPI Spec File
Generator Config
Expected Behavior
Not a crash :)
Actual Behavior
Panic + warning logs that seem incorrect.
Additional Information
Also logs shows many schemas not found, that seem correct via manual inspection: ie:
But I can find the relevant json:
Code of Conduct