Skip to content

Support issue types and fields for user-owned repositories - #3832

Draft
dewski wants to merge 4 commits into
dewski/drop-issue-fields-graphql-featuresfrom
dewski/owner-agnostic-issue-types-fields
Draft

dewski wants to merge 4 commits into
dewski/drop-issue-fields-graphql-featuresfrom
dewski/owner-agnostic-issue-types-fields

Conversation

@dewski

@dewski dewski commented Nov 12, 2026 •

Copy link
Copy Markdown

Summary

This PR makes list_issue_types, list_issue_fields, and ui_get issue_types work for user-owned repositories, not just organizations.

Why

Issue types and fields are available on user accounts now, but without repo the server assumed the owner was an organization, so user owners failed against orgs/{owner}. The issue-write app's type picker also came back empty on user-owned repositories.

What changed

I'd review commit by commit. Each one builds and passes tests on its own.

  1. Extract ownerAccountType from detectOwnerType in projects.go. No behavior change.
  2. Add issueMetadataScope (issue_metadata_scope.go), which resolves each call to a repository, organization, or the authenticated user. Without repo, an authenticated user owner uses GET /user/issue-types and user(login:) issueFields. Any other user owner gets a tool error asking for repo, since GitHub only lists a user's definitions to that user. ui_get issue_types now takes an optional repo, and the issue-write app passes it.
  3. Describe the owner as a user or organization in tool descriptions, toolset instructions, the README, and toolsnaps. Safe to skim.
  4. Stop echoing the untrusted owner argument in that tool error.

MCP impact

  • No tool or API changes
  • Tool schema or behavior changed
  • New tool added

ui_get takes an optional repo for issue_types. User owners now work as described above.

Prompts tested (tool changes only)

Covered by tool tests against mocked REST and GraphQL, not a live client:

  • "List the issue types on my account"
  • "List issue types for hubot" as a different user (error asking for repo)
  • "What issue types can I use in octocat/hello-world?"
  • Opening the issue-write app on a user-owned repository

Security / limits

  • No security or limits impact
  • Auth / permissions considered
  • Data exposure, filtering, or token/size limits considered

Owner-level calls still challenge for read:org, even for a user owner, because the challenge can't tell the two apart from the arguments. ui_get issue_types with repo challenges for repo instead.

Tool renaming

  • I am renaming tools as part of this PR (e.g. a part of a consolidation effort)
    • I have added the new tool aliases in deprecated_tool_aliases.go
  • I am not renaming tools as part of this PR

Note: if you're renaming tools, you must add the tool aliases. For more information on how to do so, please refer to the official docs.

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Not needed
  • Updated (README / docs / examples)

Regenerated the README and toolsnaps.

@dewski
dewski added this pull request to stack #3833 November 12, 2026 19:18
Comment thread pkg/github/issue_metadata_scope.go Resolved
Pull the Users.Get account type lookup out of detectOwnerType so issue
metadata can reuse it to tell a user owner from an organization. The
project probe fallback is unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 48ff87e1-24bb-49f1-887f-9f2576ab0c2d
@dewski
dewski force-pushed the dewski/owner-agnostic-issue-types-fields branch from 9ec3a65 to 001cf21 Compare November 12, 2026 19:39
dewski and others added 3 commits November 12, 2026 15:19
Issue types and issue fields are available on user accounts as well as
organizations. list_issue_types, list_issue_fields, and the ui_get
issue_types method assumed the owner was an organization when repo was
omitted, so they failed or came back empty for user-owned repositories.

Introduce issueMetadataScope (repository, organization, or the
authenticated user) and resolve it once per call. With repo, the
repository path is unchanged. Without repo, the owner's account type
picks the organization endpoints or, when the owner is the authenticated
user, GET /user/issue-types and GraphQL user(login:).issueFields. GitHub
lists a user's definitions only to that user, so any other user owner
gets a tool error asking for repo instead of a raw FORBIDDEN.

The issue-write app now passes repo to ui_get issue_types, which reads
the repository endpoint.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 48ff87e1-24bb-49f1-887f-9f2576ab0c2d
Tool descriptions, toolset instructions, the README, and toolsnaps said
issue types and fields belong to an organization. Describe the owner as
a user or organization, and note that ui_get takes an optional repo for
issue_types.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 48ff87e1-24bb-49f1-887f-9f2576ab0c2d
resolveIssueMetadataScope put the raw owner argument into the tool error
it returns for another user's account. owner comes from the model, and
go-github doesn't escape it in the users/{owner} path, so a value like
"octocat?x=..." still resolves to a real user and its extra text would
reach the model verbatim. Refer to "the owner" instead, since the model
already knows what it passed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 48ff87e1-24bb-49f1-887f-9f2576ab0c2d
@dewski
dewski force-pushed the dewski/owner-agnostic-issue-types-fields branch from f723276 to 00176cc Compare November 12, 2026 23:21
Comment thread pkg/github/tool_scopes.go
if repo, ok := arguments["repo"].(string); ok && repo != "" {
return scopes.ChallengeAll(activeScopes, scopes.Repo)
}
return scopes.ChallengeAll(activeScopes, scopes.ReadOrg)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I kept the read:org challenge for owner-level calls here and in repositoryOrOrganizationScopeAccess, even though a user owner doesn't need it. The challenge runs before the tool and only sees the arguments and the token's scopes, so it can't tell a user from an organization without an extra GET /users/{owner}.

I wonder if you'd rather we stop challenging for read:org on owner-level calls? An organization caller without it would get the API error instead of a step-up prompt, and a user caller would never be asked for a scope they don't need. read:org is a default scope, so I'd expect either case to be rare. Happy to drop it in a follow-up if that's the preference.

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.

2 participants