{"record":{"id":"bcb74756d88d9fca","repo":"dagger/dagger","slug":"failed-to-get-global-configuration-w","errorCode":null,"errorMessage":"failed to get global configuration: %w","messagePattern":"failed to get global configuration: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/codegen/generate_client.go","lineNumber":40,"sourceCode":"var generateClientCmd = &cobra.Command{\n\tUse:   \"generate-client\",\n\tShort: \"Generate a client\",\n\tPersistentPreRun: func(cmd *cobra.Command, args []string) {\n\t\t// if we got this far, CLI parsing worked just fine; no\n\t\t// need to show usage for runtime errors\n\t\tcmd.SilenceUsage = true\n\t},\n\tRunE: GenerateClient,\n}\n\nfunc GenerateClient(cmd *cobra.Command, args []string) error {\n\tctx := cmd.Context()\n\tctx = telemetry.InitEmbedded(ctx, nil)\n\tdefer telemetry.Close()\n\n\tcfg, err := getGlobalConfig(ctx, false)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to get global configuration: %w\", err)\n\t}\n\tdefer cfg.Close()\n\n\tclientConfig := &generator.ClientGeneratorConfig{\n\t\tClientDir: outputDir,\n\t}\n\n\t// If a client dir is provided, we use it.\n\tif clientDir != \"\" {\n\t\tclientConfig.ClientDir = clientDir\n\t}\n\n\tif moduleSourceID != \"\" {\n\t\tvar res struct {\n\t\t\tSource struct {\n\t\t\t\tName          string `json:\"moduleOriginalName\"`\n\t\t\t\tEngineVersion string `json:\"engineVersion\"`\n\t\t\t\tDependencies  []generator.ModuleSourceDependency","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/cmd/codegen/generate_client.go#L22-L58","documentation":"Cache.PersistedResultID extracts the numeric persisted result ID from an AnyResult, which requires the result to be backed by a cache sharedResult. If res.cacheSharedResult() returns nil the result was never stored in the cache and no persisted ID exists.","triggerScenarios":"Calling PersistedResultID on a result constructed outside the cache pipeline (e.g. a literal Typed value, a result from a different cache, or one whose shared pointer was never set via cache attach/attachResult).","commonSituations":"Extension code grabbing result IDs before the result has been attached to the cache; mixing results between two Cache instances; test-constructed results.","solutions":["Only call PersistedResultID on results returned from cache-managed paths (query evaluation, LoadResultByResultID).","Ensure the result has been attached to this Cache (attachResult/attach) before extracting its ID.","Check you are using the same Cache instance that evaluated the result.","Handle the error explicitly instead of assuming every result has a persisted ID."],"exampleFix":"// before\nid, _ := cache.PersistedResultID(literalResult) // not cache-backed\n// after\nid, err := cache.PersistedResultID(evaluatedResult) // result came from the cache pipeline\nif err != nil { return err }","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func isCacheBacked(res dagql.AnyResult) bool { return res != nil && res.CacheSharedResult() != nil }\n\nif !isCacheBacked(res) { return errors.New(\"result is not cache-backed\") }\nid, err := cache.PersistedResultID(res)","tryCatchPattern":"id, err := cache.PersistedResultID(res)\nif err != nil { return fmt.Errorf(\"no persisted ID for %T: %w\", res, err) }","preventionTips":["Only extract IDs from results produced by cache-managed APIs","Attach results to the cache before ID extraction","Use a single Cache instance per result lineage"],"tags":["dagql","cache","api-misuse"],"backgroundTag":"result-not-cache-backed","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"}