Fix DID verification method ID encoding and add controller#48
Merged
Conversation
doc.Fragment() expects a bare fragment name and prepends the "#" itself, so passing "#key-0" produced a double-hash fragment that the DID-URL serializer percent-encoded as "#%23key-0" (e.g. did:web:hilt.staging.fil.one#%23key-0). Pass "key-0" instead. Also set the verification method's Controller to the document's DID, which was previously left unset and serialized as "controller": null. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAjDX5F44mcX8ojb1ENjYt
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes DID document generation in identity to ensure verification method IDs serialize correctly (avoiding a double-encoded #) and to correctly set the verification method controller to the document DID.
Changes:
- Fix verification method fragment handling by passing a bare fragment name to
doc.Fragment(...)to avoid#being percent-encoded. - Set
vm.Controller = doc.IDso the verification method is properly associated with the DID document. - Add a test validating DID document ID, verification method ID formatting, lack of
%23, and controller correctness.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| identity/identity.go | Corrects fragment handling for verification method IDs and sets verification method controller to the document DID. |
| identity/identity_test.go | Adds coverage to validate DID document JSON output for correct id, verificationMethod[].id, and verificationMethod[].controller. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
frrist
approved these changes
Jul 23, 2026
alanshaw
approved these changes
Jul 24, 2026
bajtos
added a commit
to fil-forge/hilt
that referenced
this pull request
Jul 24, 2026
## Summary Bumps `github.com/fil-forge/libforge` from `v0.0.0-20260713100115-a3aa293b990c` (2026-07-13) to `v0.0.0-20260724113901-7fc3b2cec1ef` (2026-07-24, latest commit on the default branch). Performed via: ``` go get github.com/fil-forge/libforge@<latest-commit> go mod tidy ``` Only `go.mod` and `go.sum` change — no other dependency versions were affected. ## Changelog libforge commits brought in, from `a3aa293` (the previously-pinned "fix: make bucket optional") up to the new pin: - **Fix DID verification method ID encoding and add controller** ([#48](fil-forge/libforge#48), `7fc3b2c` / `f06be16`) — `doc.Fragment()` prepends `#` itself, so passing `"#key-0"` double-encoded to `#%23key-0` in serialized DID documents (e.g. `did:web:hilt.staging.fil.one#%23key-0`); now passes `"key-0"`. Also sets the verification method's `Controller` to the document DID, which previously serialized as `null`. - **Add `/ucan/revoke` command** ([#47](fil-forge/libforge#47), `aba2bd2`) — new bound command for UCAN revocation. - **Add space to `/blob/remove`, `/blob/abort`, and `/blob/reject`** (`aac837a`) — `/blob/abort` now carries a required `Cause` (the `/space/blob/add` task link); adds `/blob/reject` (upload service → storage node) so a parked blob has two mutually exclusive exits (`/blob/accept` to commit, `/blob/reject` to unwind). ## Verification The standard loop from `AGENTS.md` passes with the new version selected: - `go build ./...` — ok - `go vet ./...` — ok - `go test ./...` — all packages pass (memory backends; testcontainer-backed tests skip without Docker, as documented) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixed the DID document generation to correctly encode verification method IDs and set the controller field.
Key Changes
doc.Fragment("#key-0")todoc.Fragment("key-0")to prevent double-encoding of the#character. TheFragment()method automatically prepends#, so passing#key-0resulted in#%23key-0in the serialized output.vm.Controller = doc.IDto properly associate the verification method with the DID document.TestDIDDocument) that validates:did:web:example.com#key-0Implementation Details
The fix ensures that DID documents conform to the W3C DID specification by properly formatting the verification method ID and establishing the correct controller relationship.
https://claude.ai/code/session_01YAjDX5F44mcX8ojb1ENjY
References