dagger/dagger · error

decode persisted git repository: unsupported form %q

Error message

decode persisted git repository: unsupported form %q

What it means

DecodePersistedObject switches on persisted.Form (local or remote). Any other form value — including empty or unknown enum strings — hits the default branch and errors with 'decode persisted git repository: unsupported form %q'. It indicates the payload's form discriminator is unrecognized by this decoder version.

Source

Thrown at core/git.go:573

			URL:           parsedURL,
			SSHKnownHosts: persisted.Remote.SSHKnownHosts,
			AuthUsername:  persisted.Remote.AuthUsername,
			Platform:      persisted.Remote.Platform,
		}
		var mirror dagql.ObjectResult[*RemoteGitMirror]
		if err := dag.Select(ctx, dag.Root(), &mirror, dagql.Selector{
			Field: "_remoteGitMirror",
			Args: []dagql.NamedInput{
				{Name: "remoteURL", Value: dagql.String(parsedURL.Remote())},
			},
		}); err != nil {
			return nil, fmt.Errorf("decode persisted git repository remote mirror: %w", err)
		}
		backend.Mirror = mirror
		repo.Backend = backend
		repo.URL = dagql.NonNull(dagql.String(parsedURL.String()))
	default:
		return nil, fmt.Errorf("decode persisted git repository: unsupported form %q", persisted.Form)
	}
	return repo, nil
}

type persistedGitRefPayload struct {
	RepoResultID uint64 `json:"repoResultID"`
	Name         string `json:"name,omitempty"`
	SHA          string `json:"sha"`
}

func (ref *GitRef) EncodePersistedObject(ctx context.Context, cache dagql.PersistedObjectCache) (dagql.PersistedObjectEncoding, error) {
	_ = ctx
	if ref == nil {
		return dagql.PersistedObjectEncoding{}, fmt.Errorf("encode persisted git ref: nil ref")
	}
	if ref.Ref == nil {
		return dagql.PersistedObjectEncoding{}, fmt.Errorf("encode persisted git ref: missing ref")
	}

View on GitHub (pinned to 82ba2681db)

Solutions

  1. Check the quoted form value in the error against the persistedGitRepositoryForm* constants
  2. Re-create the repository so a fresh payload with a known form is written
  3. Align encoder/decoder enum constants across versions; add a case for the new form
  4. Clear stale persisted data written by an incompatible version

Example fix

// before
default:
	return nil, fmt.Errorf("decode persisted git repository: unsupported form %q", persisted.Form)
// after
case persistedGitRepositoryFormBundle:
	// handle new form
default:
	return nil, fmt.Errorf("decode persisted git repository: unsupported form %q", persisted.Form)
Defensive patterns

Strategy: validation

Validate before calling

var probe struct{ Form string `json:"form"` }
json.Unmarshal(payload, &probe)
switch probe.Form {
case "local", "remote": // known forms
default:
	// unknown form: payload from incompatible version; recreate
}

Type guard

func knownGitRepoForm(form string) bool {
	return form == "local" || form == "remote"
}

Try / catch

if err != nil && strings.Contains(err.Error(), "unsupported form") {
	// discard stale ID and recreate the GitRepository with the current SDK version
}

Prevention

When it happens

Trigger: Decoding a payload whose persisted.Form is empty, corrupted, or was written by a newer/older version using a form constant this decoder doesn't know.

Common situations: Dagger upgraded: a new persistedGitRepositoryForm constant was added in the encoder but the decoder (or vice versa) wasn't updated; cache data from a different version; payload corruption flipping the form string.

Related errors


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