Skip to content

Fix revoke failing due to incorrect annotation type in Pick()#49

Open
c1-dev-bot[bot] wants to merge 2 commits intomainfrom
fix/revoke-grant-metadata-annotation
Open

Fix revoke failing due to incorrect annotation type in Pick()#49
c1-dev-bot[bot] wants to merge 2 commits intomainfrom
fix/revoke-grant-metadata-annotation

Conversation

@c1-dev-bot
Copy link

@c1-dev-bot c1-dev-bot bot commented Mar 5, 2026

Summary

  • Fixes team membership revoke (deprovisioning) failing with error: baton-linear: annotation does not exist: %!w(<nil>)
  • Root cause: Revoke() used annos.Pick(&structpb.Struct{}) but WithGrantMetadata() stores metadata as v2.GrantMetadata (a different protobuf type). Pick() uses MessageIs() to match by type URL, so it never found the annotation.
  • Fix: Pick the correct v2.GrantMetadata type, then extract the inner Metadata struct. Also fixes nil error wrapping that produced the malformed %!w(<nil>) in the error message.

Test plan

  • Verify go build ./... passes (confirmed locally)
  • Verify go vet ./... passes (confirmed locally)
  • Deploy updated connector and test revoking a user's team membership in Linear
  • Confirm the revoke operation succeeds and the user is removed from the team

Automated PR Notice

This PR was automatically created by c1-dev-bot as a potential implementation.

This code requires:

  • Human review of the implementation approach
  • Manual testing to verify correctness
  • Approval from the appropriate team before merging

The Revoke method was using annos.Pick(&structpb.Struct{}) to extract
grant metadata, but WithGrantMetadata() stores it as a GrantMetadata
protobuf message (which wraps structpb.Struct). Since Pick() uses
MessageIs() to match by protobuf type URL, it never found a matching
annotation and returned (false, nil). The nil error was then incorrectly
wrapped with %w, producing the malformed error message:
"annotation does not exist: %!w(<nil>)"

Fix: Pick the correct v2.GrantMetadata type, then extract the inner
Metadata struct from it. Also fix the error message to not wrap nil.
@c1-dev-bot c1-dev-bot bot requested a review from a team March 5, 2026 20:54
Whitespace formatting in the generated JSON changed due to Go version
differences. Update the committed file to match.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Claude finished @c1-dev-bot[bot]'s task in 1m 16s —— View job


PR Review: Fix revoke failing due to incorrect annotation type in Pick()

Blocking Issues: 0 | Suggestions: 0

  • Gather context and read changed files
  • Review code changes against criteria
  • Post review feedback

Security Issues

None found.

Correctness Issues

None found. The fix is correct:

  1. Type mismatch fix (team.go:179-190): WithGrantMetadata() stores metadata as v2.GrantMetadata, but the old code used annos.Pick(&structpb.Struct{}). Since Pick() uses MessageIs() to match by protobuf type URL, it never matched. Changing to &v2.GrantMetadata{} and then extracting the inner *structpb.Struct via GetMetadata() is the correct approach.

  2. Nil error wrapping fix (team.go:187): The old code had fmt.Errorf("...%w", err) in the !ok branch where err was always nil, producing the malformed %!w(<nil>) output. Replacing with a plain error string is correct.

  3. Nil metadata check (team.go:191-193): Good defensive check before accessing metadata.Fields.

Suggestions

None. The baton_capabilities.json changes are cosmetic whitespace normalization (removing extra spaces before colons) — harmless.

This is a clean, focused bug fix that correctly addresses the root cause.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants