Summary #
tg repo set-default-branch sends the legacy sh.tangled.repo record AT-URI to sh.tangled.repo.setDefaultBranch. Current Knots that advertise repo-did-input require the repository DID instead, so the command fails with invalid repo DID.
The same call path is used by repo create --push when it tries to set the pushed branch as the default, so creation can succeed with a warning while the default-branch RPC fails.
Reproduction #
Using tg 0.4.0 built from c2391cb2f22526bcb0beb1b84c7764084436f9e7:
$ tg repo set-default-branch main sensemaker.computer/forecast-graph
Error: set default branch to "main": invalid repo DID
Repository metadata:
record: at://did:plc:4j7exarb62djxycrgdfhuulr/sh.tangled.repo/forecast-graph
repoDid: did:plc:ukx2jazsskfqmc2tlxygyx57
knot: knot1.tangled.sh
Production Knot reports:
{
"version": "v1.15.0",
"capabilities": ["knot-acl", "repo-did-input"]
}
Cause #
In internal/app/repo_set_default_branch.go, SetRepoDefaultBranch resolves the repository record but passes repo.URI into setKnotDefaultBranch. knot/repo_set_default_branch.go still documents the field as the AT-URI of the sh.tangled.repo record.
Tangled core commit 560b5c84e1099fe1a064ef38c562f8180423908e changed sh.tangled.repo.setDefaultBranch's repo input from format: at-uri to format: did. Tangled's appview handles the migration with knotcompat.RepoArg: it probes sh.tangled.knot.version, sends repoDid when repo-did-input is advertised, and falls back to the record AT-URI for older Knots.
Expected behavior #
tg should set the default branch successfully against current Knots without breaking older or self-hosted Knots.
Suggested direction #
Mirror the appview's capability negotiation:
- fetch the Knot version/capabilities;
- when
repo-did-inputis present and the repository record has a validrepoDid, send that DID; - otherwise send the legacy record AT-URI;
- cover new-Knot, legacy-Knot, missing/invalid
repoDid, and failed-probe cases in tests; - apply the same behavior to both the explicit command and the
repo create --pushpath.
The repository in this reproduction is not left broken: its first main push established public HEAD as refs/heads/main. The issue is the CLI/RPC compatibility path.
should be fixed in latest master!