Make CreateRef idempotent for componentized OAS input#2010
Make CreateRef idempotent for componentized OAS input#2010TinaHeiligers wants to merge 3 commits intoelastic:mainfrom
Conversation
When the target path doesn't exist (because the Kibana componentizer already extracted it to a $ref), skip gracefully instead of panicking. Also skip when the target is already a $ref. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
I actually see this as a good thing TBH. It's a clear signal that we can clean something up in
With the alternative (this PR), we still have to eventually clean up
Whilst it reduces the short term friction, IMO the overall human in the loop cost is higher. We're also assuming an exact 1:1 component renaming, I understand that's the goal, but any time we don't accomplish that we're left with the same blocking change anyway. If it we me, we'd close this PR and address the changes as they arise, WDYT? |
|
Closing as not needed. The clean-up work will be handled through the renovate workflow |
|
FYI, without the changes in this PR, |
|
@tobio I've only seen https://github.com/elastic/private-repo-triage/issues/3030 today. Should we go with this PR or the changes suggested in https://github.com/elastic/private-repo-triage/issues/3030#issuecomment-4120853111? |
|
@tobio I tested the current Kibana main OAS against the provider's transform pipeline: Panic in This PR works for All three of those transforms are now dead code because elastic/kibana#258986 already fixed them in Kibana (kafka types, discriminator, id removal). So the real fix on the next Renovate bump is: merge this PR for
That cleanup can happen in the Renovate PR itself since the build failure makes it obvious which code to remove. This PR just ensures |
TBH I feel like this backs up my hesitation around this PR. It would have had a negligible impact on the work involved in getting #2031 merged. There were multiple changes required to the transformation here, followed up with wider changes adopting the new client code in the provider. With this PR merged, we would have saved maybe 30 seconds, but have left this now redundant code block around for someone to investigate in the future. At the moment, I don't see any tangible benefit in going down this path. |
Closes #2009
Why
Kibana is progressively improving its OAS output by adding named components to schemas via
meta:{id}onkbn-config-schematypes. When a Kibana plugin addsmeta:{id}, the OAS bundler produces a$refto a named component instead of an inline schema.The provider's
CreateReffunction currently panics when:$ref(Kibana produced a reference instead of inline)This blocks the provider from consuming improved Kibana OAS output without per-change updates to
transform_schema.go.What
Makes
CreateRefidempotent by adding two guards:Getinstead ofMustGet. When the target path doesn't exist, logs a message and returns the$refvalue without panicking. This handles cases where Kibana's componentizer has already extracted the schema.$ref: Detects when the target is already a$ref(bothMapandmap[string]anyvariants) and returns early without re-extracting.No behavioral change for existing OAS input — the guards only activate when Kibana produces componentized output.
Motivation
Kibana PR elastic/kibana#258986 is the first change adding
meta:{id}to fleet output schemas, producing named components. More Kibana plugins will follow this pattern as part of the ongoing OAS quality initiative.Test plan
CreateRefcovering:$ref(Map type) — returns without panic$ref(map[string]any type) — returns without panicgo build ./...passeskibana.yamlNote
Make
Map.CreateRefidempotent for componentized OAS inputCreateRefin transform_schema.go previously panicked when the target path was missing or already a$ref, causing failures on pre-componentized OpenAPI schemas.Getlookup so missing paths log a message and return the$refwithout mutating the map.$ref(bothMapandmap[string]anytypes), skipping component registration.Macroscope summarized d4304a8.