From ee83aaa82e9a3d213f2942ddc745bcc0bc2bf132 Mon Sep 17 00:00:00 2001 From: Andrei Kvapil Date: Thu, 12 Mar 2026 23:58:55 +0100 Subject: [PATCH] fix(api): skip OpenAPI post-processor for non-apps group versions The OpenAPI PostProcessSpec callback is invoked for every group-version (apps, core, version, etc.), but the Application schema cloning logic only applies to apps.cozystack.io. When called for other GVs the base Application schemas are absent, causing a spurious error log on every API server start. Return early instead of erroring when the base schemas are not found. Co-Authored-By: Claude Signed-off-by: Andrei Kvapil --- pkg/cmd/server/openapi.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/cmd/server/openapi.go b/pkg/cmd/server/openapi.go index 616709ca..5d1b35db 100644 --- a/pkg/cmd/server/openapi.go +++ b/pkg/cmd/server/openapi.go @@ -224,8 +224,8 @@ func buildPostProcessV3(kindSchemas map[string]string) func(*spec3.OpenAPI) (*sp base, ok1 := doc.Components.Schemas[baseRef] list, ok2 := doc.Components.Schemas[baseListRef] stat, ok3 := doc.Components.Schemas[baseStatusRef] - if !(ok1 && ok2 && ok3) && len(kindSchemas) > 0 { - return doc, fmt.Errorf("base Application* schemas not found") + if !(ok1 && ok2 && ok3) { + return doc, nil // not the apps GV — nothing to patch } // Clone base schemas for each kind @@ -339,8 +339,8 @@ func buildPostProcessV2(kindSchemas map[string]string) func(*spec.Swagger) (*spe base, ok1 := defs[baseRef] list, ok2 := defs[baseListRef] stat, ok3 := defs[baseStatusRef] - if !(ok1 && ok2 && ok3) && len(kindSchemas) > 0 { - return sw, fmt.Errorf("base Application* schemas not found") + if !(ok1 && ok2 && ok3) { + return sw, nil // not the apps GV — nothing to patch } for kind, raw := range kindSchemas {