{"record":{"id":"34d1fdcff06c6856","repo":"istio/istio","slug":"expecting-a-workload-namespace","errorCode":null,"errorMessage":"expecting a workload namespace","messagePattern":"expecting a workload namespace","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"istioctl/pkg/workload/workload.go","lineNumber":134,"sourceCode":"\t}\n\tentryCmd.AddCommand(configureCommand(ctx))\n\treturn entryCmd\n}\n\nfunc createCommand(ctx cli.Context) *cobra.Command {\n\tcreateCmd := &cobra.Command{\n\t\tUse:   \"create\",\n\t\tShort: \"Creates a WorkloadGroup resource that provides a template for associated WorkloadEntries\",\n\t\tLong: `Creates a WorkloadGroup resource that provides a template for associated WorkloadEntries.\nThe default output is serialized YAML, which can be piped into 'kubectl apply -f -' to send the artifact to the API Server.`,\n\t\tExample: \"  istioctl x workload group create --name foo --namespace bar --labels app=foo,bar=baz \" +\n\t\t\t\"--ports grpc=3550,http=8080 --annotations annotation=foobar --serviceAccount sa\",\n\t\tArgs: func(cmd *cobra.Command, args []string) error {\n\t\t\tif name == \"\" {\n\t\t\t\treturn fmt.Errorf(\"expecting a workload name\")\n\t\t\t}\n\t\t\tif namespace == \"\" {\n\t\t\t\treturn fmt.Errorf(\"expecting a workload namespace\")\n\t\t\t}\n\t\t\treturn nil\n\t\t},\n\t\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\t\tu := &unstructured.Unstructured{\n\t\t\t\tObject: map[string]any{\n\t\t\t\t\t\"apiVersion\": gvk.WorkloadGroup.GroupVersion(),\n\t\t\t\t\t\"kind\":       gvk.WorkloadGroup.Kind,\n\t\t\t\t\t\"metadata\": map[string]any{\n\t\t\t\t\t\t\"name\":      name,\n\t\t\t\t\t\t\"namespace\": namespace,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}\n\t\t\tspec := &networkingv1alpha3.WorkloadGroup{\n\t\t\t\tMetadata: &networkingv1alpha3.WorkloadGroup_ObjectMeta{\n\t\t\t\t\tLabels:      convertToStringMap(resourceLabels),\n\t\t\t\t\tAnnotations: convertToStringMap(annotations),","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/istio/istio/blob/8dc789c5cf17517c64e3c36cb3288230f149dfae/istioctl/pkg/workload/workload.go#L116-L152","documentation":"Second validator in `istioctl x workload group create` (istioctl/pkg/workload/workload.go:134): after the name check passes, the namespace flag must also be non-empty because the generated WorkloadGroup manifest embeds metadata.namespace. Raised as `expecting a workload namespace` before any output is produced.","triggerScenarios":"`istioctl x workload group create --name foo` with no -n/--namespace and no default; namespace flag empty because the shell variable expanded to nothing.","commonSituations":"Unlike core istioctl commands this experimental command does not fall back to the kubeconfig default namespace, surprising users; script variables unset; namespace typo'd into another flag.","solutions":["Pass the namespace explicitly: `istioctl x workload group create --name foo --namespace bar`","Or set the ambient default: `kubectl config set-context --current --namespace=bar` before re-running (if your istioctl honors it)","Validate both NAME and NAMESPACE variables in the calling script first"],"exampleFix":"# before\nistioctl x workload group create --name foo\n# after\nistioctl x workload group create --name foo --namespace bar","handlingStrategy":"validation","validationCode":": \"${NAME:?--name required}\"; : \"${NAMESPACE:?--namespace required}\"\nistioctl x workload group create --name \"$NAME\" --namespace \"$NAMESPACE\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember this experimental command does NOT default the namespace from kubeconfig — always pass -n","Validate both NAME and NAMESPACE in one guard block before the CLI call","Lint scripts with shellcheck to catch unset-variable flag expansions early"],"tags":["istioctl","workload","vm","cli-usage","argument-validation"],"backgroundTag":null,"analyzedSha":"8dc789c5cf17517c64e3c36cb3288230f149dfae","analyzedAt":"2026-08-15T15:16:55.434Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}