{"record":{"id":"f327fa3653f3e47b","repo":"portainer/portainer","slug":"unable-to-determine-resource-type","errorCode":null,"errorMessage":"unable to determine resource type","messagePattern":"unable to determine resource type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/libkubectl/apply_dynamic.go","lineNumber":173,"sourceCode":"// When dryRun is set the request is sent with dry-run=All, so the API server validates it without persisting it.\nfunc (c *Client) applyResource(ctx context.Context, setup *applySetup, resourceYAML []byte, dryRun bool) (appliedResource, error) {\n\tvar applied appliedResource\n\n\tobj := &unstructured.Unstructured{}\n\tdecoder := yaml.NewYAMLOrJSONDecoder(strings.NewReader(string(resourceYAML)), 4096)\n\tif err := decoder.Decode(obj); err != nil {\n\t\treturn applied, fmt.Errorf(\"failed to decode YAML: %w\", err)\n\t}\n\n\t// Skip empty objects\n\tif obj.Object == nil {\n\t\treturn applied, nil\n\t}\n\n\t// Get GVK (GroupVersionKind) from the object\n\tgvk := obj.GroupVersionKind()\n\tif gvk.Empty() {\n\t\treturn applied, errors.New(\"unable to determine resource type\")\n\t}\n\n\tapplied.Kind = gvk.Kind\n\tapplied.Name = obj.GetName()\n\n\t// Map GVK to GVR (GroupVersionResource)\n\tmapping, err := setup.mapper.RESTMapping(gvk.GroupKind(), gvk.Version)\n\tif err != nil {\n\t\treturn applied, fmt.Errorf(\"failed to map resource type %s: %w\", gvk.String(), err)\n\t}\n\n\t// Get the dynamic resource client\n\tvar resourceClient dynamic.ResourceInterface\n\n\tif mapping.Scope.Name() == meta.RESTScopeNameNamespace {\n\t\tnamespace, err := resolveNamespace(setup.configuredNamespace, obj.GetNamespace())\n\t\tif err != nil {\n\t\t\treturn applied, fmt.Errorf(\"namespace conflict for %s %q: %w\", gvk.Kind, applied.Name, err)","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/portainer/portainer/blob/17e74456ff6e794b9d5439ec3fa06922aa18a3f8/pkg/libkubectl/apply_dynamic.go#L155-L191","documentation":"Error \"unable to determine resource type\" thrown in portainer/portainer.","triggerScenarios":"Thrown at pkg/libkubectl/apply_dynamic.go:173 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"17e74456ff6e794b9d5439ec3fa06922aa18a3f8","analyzedAt":"2026-08-26T23:09:01.915Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}