{"record":{"id":"229c0ff30f5ef8ca","repo":"dagger/dagger","slug":"global-writes-to-user-level-config-pass-key-val","errorCode":null,"errorMessage":"--global writes to user-level config; pass KEY VALUE to set or --unset KEY (reads always show the effective merged config)","messagePattern":"--global writes to user-level config; pass KEY VALUE to set or --unset KEY \\(reads always show the effective merged config\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cmd/dagger/workspace.go","lineNumber":263,"sourceCode":"\taddWorkspaceHereFlag(workspaceConfigCmd)\n\tactivityCmd.Flags().BoolVarP(&workspaceActivityAll, \"all\", \"a\", false, \"Show activity from all remotes in the current workspace\")\n}\n\nfunc addWorkspaceHereFlag(cmd *cobra.Command) {\n\tcmd.Flags().BoolVar(&workspaceHere, \"here\", false, \"Write workspace config at the selected workspace cwd\")\n}\n\nfunc runWorkspaceConfig(cmd *cobra.Command, args []string) error {\n\tif workspaceConfigUnset && len(args) != 1 {\n\t\treturn fmt.Errorf(\"--unset requires a KEY argument\")\n\t}\n\tif workspaceConfigGlobal {\n\t\tctx := cmd.Context()\n\t\tif workspaceConfigUnset {\n\t\t\treturn unsetUserConfigValue(ctx, userScopedConfigKey(args[0]))\n\t\t}\n\t\tif len(args) != 2 {\n\t\t\treturn fmt.Errorf(\"--global writes to user-level config; pass KEY VALUE to set or --unset KEY (reads always show the effective merged config)\")\n\t\t}\n\t\treturn writeUserConfigValue(ctx, userScopedConfigKey(args[0]), args[1], nil)\n\t}\n\treturn withEngine(cmd.Context(), client.Params{\n\t\tSkipWorkspaceModules:           true,\n\t\tSuppressCompatWorkspaceWarning: true,\n\t}, func(ctx context.Context, engineClient *client.Client) error {\n\t\tws := engineClient.Dagger().CurrentWorkspace()\n\n\t\tif workspaceConfigUnset {\n\t\t\treturn ws.WithoutConfigValue(args[0], dagger.WorkspaceWithoutConfigValueOpts{Here: workspaceHere}).Export(ctx)\n\t\t}\n\n\t\tswitch len(args) {\n\t\tcase 0:\n\t\t\treturn printWorkspaceConfig(ctx, cmd.OutOrStdout(), ws, \"\")\n\t\tcase 1:\n\t\t\treturn printWorkspaceConfig(ctx, cmd.OutOrStdout(), ws, args[0])","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/internal/cmd/dagger/workspace.go#L245-L281","documentation":"Argument validation error from `dagger workspace config --global`: --global writes to user-level config, which supports only KEY VALUE writes (2 args) or --unset KEY (1 arg). Reads of the effective merged config are done without --global, so --global with fewer than 2 arguments (and no --unset) is rejected with this explanatory message.","triggerScenarios":"Running `dagger workspace config --global` with 0 arguments (intending a read), or `dagger workspace config --global KEY` with only one argument (intending a read of one key, or omitting the VALUE).","commonSituations":"Assuming --global also applies to reads; omitting the value in a scripted set; migrating from a plain `dagger workspace config KEY` read and adding --global by habit.","solutions":["For writes, pass exactly two arguments: `dagger workspace config --global KEY VALUE`.","For reads, drop --global: `dagger workspace config` or `dagger workspace config KEY` shows the effective merged config.","For removal, use `dagger workspace config --global --unset KEY`.","Note the write is keyed by the workspace's git remote; ensure the workspace has a git origin."],"exampleFix":"// before\ndagger workspace config --global autocheck\n// error: --global writes to user-level config; pass KEY VALUE ...\n// after\ndagger workspace config autocheck              # read (merged)\ndagger workspace config --global autocheck on  # write","handlingStrategy":"validation","validationCode":"if global && !unset && len(args) != 2 {\n    return fmt.Errorf(\"--global requires KEY VALUE\")\n}\n// reads:\n// dagger workspace config KEY      (no --global)\n// writes:\n// dagger workspace config --global KEY VALUE","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use --global only for writes (KEY VALUE) and --unset KEY, never for reads.","Reads without --global show the effective merged config including user-level values.","Ensure the workspace has a git origin so user-level config can be keyed."],"tags":["cli","argument-validation","config"],"backgroundTag":"missing-required-argument","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}