{"record":{"id":"fd133ce5522d848e","repo":"argoproj/argo-workflows","slug":"cannot-use-instance-id-with-argo-server","errorCode":null,"errorMessage":"cannot use instance ID with Argo Server","messagePattern":"cannot use instance ID with Argo Server","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apiclient/apiclient.go","lineNumber":73,"sourceCode":"\tlog := logging.GetLoggerFromContextOrNil(ctx)\n\tif log == nil {\n\t\tlogLevel, err := logging.ParseLevelOr(opts.LogLevel, logging.Info)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t\tlogFormat, err := logging.TypeFromStringOr(opts.LogFormat, logging.Text)\n\t\tif err != nil {\n\t\t\treturn nil, nil, err\n\t\t}\n\t\tlog = logging.NewSlogLogger(logLevel, logFormat)\n\t\tctx = logging.WithLogger(ctx, log)\n\t}\n\tlog.WithField(\"opts\", opts).Debug(ctx, \"Client options\")\n\tif opts.Offline {\n\t\treturn newOfflineClient(ctx, opts.OfflineFiles)\n\t}\n\tif opts.ArgoServerOpts.URL != \"\" && opts.InstanceID != \"\" {\n\t\treturn nil, nil, fmt.Errorf(\"cannot use instance ID with Argo Server\")\n\t}\n\tswitch {\n\tcase opts.ArgoServerOpts.HTTP1:\n\t\tif opts.AuthSupplier == nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"AuthSupplier cannot be empty when connecting to Argo Server\")\n\t\t}\n\t\treturn newHTTP1Client(ctx, opts.ArgoServerOpts, opts.AuthSupplier(), opts.Proxy)\n\tcase opts.ArgoServerOpts.URL != \"\":\n\t\tif opts.AuthSupplier == nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"AuthSupplier cannot be empty when connecting to Argo Server\")\n\t\t}\n\t\treturn newArgoServerClient(ctx, opts.ArgoServerOpts, opts.AuthSupplier())\n\tdefault:\n\t\tif opts.ClientConfigSupplier != nil {\n\t\t\topts.ClientConfig = opts.ClientConfigSupplier()\n\t\t}\n\t\treturn newArgoKubeClient(ctx, opts.ArgoKubeOpts, opts.ClientConfig, instanceid.NewService(opts.InstanceID))\n\t}","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/argoproj/argo-workflows/blob/35bff19146f5a6ada77468c431f2624bd577e373/pkg/apiclient/apiclient.go#L55-L91","documentation":"NewClientFromOptsWithContext rejects Opts that combine an Argo Server URL (opts.ArgoServerOpts.URL) with an instance ID. Instance-ID filtering is implemented server-side by the argo-server; when going through the server the client must not set one separately, so the combination is treated as a configuration contradiction and returns an error (note: returns nil client, nil error wrapper — check for the error before use).","triggerScenarios":"Creating an API client via apiclient.NewAPIClient / NewClientFromOptsWithContext with Opts{ArgoServerOpts: {URL: \"https://argo.example:2746\"}, InstanceID: \"my-instance\"} — e.g. running the argo CLI with both --argo-server and an ARGO_INSTANCEID env var set.","commonSituations":"CI environments where ARGO_INSTANCEID is exported globally for the controller while a script also points at the Argo Server; mixing flags --instanceid with --argo-server on the CLI; copying example code that sets both.","solutions":["Remove the InstanceID from Opts when connecting through the Argo Server (the server applies its own instance ID)","Unset the ARGO_INSTANCEID env var for CLI/server-based access, or drop --argo-server to use direct-kube access where an instance ID is valid","Set the instance ID on the server (server --instanceid) instead of the client"],"exampleFix":"// before\nclient, err := apiclient.NewAPIClient(ctx, apiclient.Opts{ArgoServerOpts: apiclient.ArgoServerOpts{URL: url}, InstanceID: \"x\"})\n// after\nclient, err := apiclient.NewAPIClient(ctx, apiclient.Opts{ArgoServerOpts: apiclient.ArgoServerOpts{URL: url}})","handlingStrategy":"validation","validationCode":"func buildOpts(serverURL, instanceID string) (apiclient.Opts, error) {\n    if serverURL != \"\" && instanceID != \"\" {\n        return apiclient.Opts{}, errors.New(\"InstanceID is controller-side; do not combine with ArgoServerOpts.URL\")\n    }\n    return apiclient.Opts{ArgoServerOpts: apiclient.ArgoServerOpts{URL: serverURL}, InstanceID: instanceID}, nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never export ARGO_INSTANCEID globally in environments that also use the Argo Server","Set the instance ID on the server process, not the client","Audit env vars in CI runners for ARGO_INSTANCEID before running argo CLI"],"tags":["cli","configuration","grpc","client"],"backgroundTag":"conflicting-client-options","analyzedSha":"35bff19146f5a6ada77468c431f2624bd577e373","analyzedAt":"2026-09-03T19:34:35.908Z","contentChangedAt":"2026-09-03T19:34:35.908Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}