dagger/dagger · error

failed to get global configuration: %w

Error message

failed to get global configuration: %w

What it means

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.

Source

Thrown at cmd/codegen/generate_client.go:40

var generateClientCmd = &cobra.Command{
	Use:   "generate-client",
	Short: "Generate a client",
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		// if we got this far, CLI parsing worked just fine; no
		// need to show usage for runtime errors
		cmd.SilenceUsage = true
	},
	RunE: GenerateClient,
}

func GenerateClient(cmd *cobra.Command, args []string) error {
	ctx := cmd.Context()
	ctx = telemetry.InitEmbedded(ctx, nil)
	defer telemetry.Close()

	cfg, err := getGlobalConfig(ctx, false)
	if err != nil {
		return fmt.Errorf("failed to get global configuration: %w", err)
	}
	defer cfg.Close()

	clientConfig := &generator.ClientGeneratorConfig{
		ClientDir: outputDir,
	}

	// If a client dir is provided, we use it.
	if clientDir != "" {
		clientConfig.ClientDir = clientDir
	}

	if moduleSourceID != "" {
		var res struct {
			Source struct {
				Name          string `json:"moduleOriginalName"`
				EngineVersion string `json:"engineVersion"`
				Dependencies  []generator.ModuleSourceDependency

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Only call PersistedResultID on results returned from cache-managed paths (query evaluation, LoadResultByResultID).
  2. Ensure the result has been attached to this Cache (attachResult/attach) before extracting its ID.
  3. Check you are using the same Cache instance that evaluated the result.
  4. Handle the error explicitly instead of assuming every result has a persisted ID.

Example fix

// before
id, _ := cache.PersistedResultID(literalResult) // not cache-backed
// after
id, err := cache.PersistedResultID(evaluatedResult) // result came from the cache pipeline
if err != nil { return err }
Defensive patterns

Strategy: type-guard

Type guard

func isCacheBacked(res dagql.AnyResult) bool { return res != nil && res.CacheSharedResult() != nil }

if !isCacheBacked(res) { return errors.New("result is not cache-backed") }
id, err := cache.PersistedResultID(res)

Try / catch

id, err := cache.PersistedResultID(res)
if err != nil { return fmt.Errorf("no persisted ID for %T: %w", res, err) }

Prevention

When it happens

Trigger: 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).

Common situations: Extension code grabbing result IDs before the result has been attached to the cache; mixing results between two Cache instances; test-constructed results.

Related errors


AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05). Data as JSON: /api/errors/bcb74756d88d9fca. Report an issue: GitHub.