Skip to content

fix: resolve issue label names against organization labels - #47

Open
M-Kerr wants to merge 3 commits into
escidmore:mainfrom
M-Kerr:M-Kerr/fix-org-labels
Open

M-Kerr wants to merge 3 commits into
escidmore:mainfrom
M-Kerr:M-Kerr/fix-org-labels

Conversation

@M-Kerr

@M-Kerr M-Kerr commented Oct 4, 2026 •

Copy link
Copy Markdown

Problem

issue create --repo org/repo --label NAME failed with Repository has no label named NAME (LABEL_NOT_FOUND, exit 2) when NAME is a label defined on the owning organization rather than in the repository. Label names were resolved against GET repos/{owner}/{repo}/labels only; GET orgs/{org}/labels was never consulted. Forgejo itself accepts organization label ids in the same labels list (checked in the v15.0 and v16.0 sources: issue create, PUT issues/{n}/labels, and the issue-list labels filter all accept or resolve organization labels), so the fix is in name resolution, not a new flag.

What changed

  • issue create, issue edit and the issue list --label filter resolve names against the repository's labels first. Only names the repository leaves unresolved are looked up in orgs/{owner}/labels, so a repository label wins over an organization label of the same name and the common case makes no extra request.
  • A user owner answers 404 on the organization route; that is treated as "no organization labels" and the existing LABEL_NOT_FOUND wording and help are unchanged.
  • A name found in neither set keeps the repository wording and adds a second help entry pointing at forgejo-axi api GET orgs/{owner}/labels --paginate.
  • When the token cannot read organization labels (403; Forgejo's /orgs routes require read:organization), resolution still fails with LABEL_NOT_FOUND (exit 2) plus the additive details.organization_labels: "forbidden" and a help entry naming the scope. The hint is conditional ("If <owner> is an organization, ...") because Forgejo checks the token scope before it checks whether the owner is an organization, so a user-owned repository with a narrow token gets the same 403.
  • Two organization labels with one name raise LABEL_AMBIGUOUS, worded "Organization has N labels named X". Any other organization-route failure propagates as that failure.
  • Contract additions only: docs/contract.md and the --label help text for the issue commands describe the resolution order; skills/forgejo-axi/SKILL.md was regenerated with npm run gen:skill; README.md gained one sentence; docs/live-test-matrix.md records organization label resolution as not yet covered live.

Deliberately not changed

  • No new flag. Resolution is enough because Forgejo takes organization label ids in the existing list.
  • The label family (list/create/edit/delete) stays repository-only. It manages repository labels; reading or writing organization labels through it is a separate feature.
  • No live-lane coverage for organization labels. It needs an organization-owned repository and a label created on the organization, which is outside the disposable repository the lanes are approved to mutate.

Testing

  • npm run check passes (lint, typecheck, 279 unit tests, skill drift check, smoke test).
  • Ten new fake-server tests in test/issue.test.ts cover: create with an organization label on 15 and 16 fixtures, edit (and its no-op repeat), the list filter, repository-wins shadowing with no organization request, the user-owner 404, the name-in-neither-set hint, the 403 scope error, organization ambiguity, and a 500 that propagates. They fail before the fix (9 of 10 on the base src/forgejo.ts) and pass after it.
  • Neither live lane (npm run test:live -- 15 / -- 16) was run. My machine cannot decrypt the live-host environment, so a maintainer needs to run both lanes. Real-host behaviour for organization labels is unverified by this PR; the claims above about Forgejo's acceptance of organization label ids come from reading its source.

M-Kerr added 3 commits October 4, 2026 11:23
Issue create, issue edit, and the issue list label filter resolved label
names against repository labels only, so a label defined on the owning
organization failed with LABEL_NOT_FOUND even though Forgejo accepts
organization label ids in the same list.

Names the repository leaves unresolved are now looked up in the owning
organization's labels. A repository label wins over an organization label
of the same name, and the organization is not asked when the repository
resolves every name. A user owner (404 on the organization route) keeps
the previous error unchanged; a token that cannot read organization labels
(403) gets LABEL_NOT_FOUND with details.organization_labels "forbidden"
and a hint naming the read:organization scope. The label family still
manages repository labels only.
@coderabbitai

coderabbitai Bot commented Oct 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c6112d41-531f-46d3-b63f-9f32b1be4699

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant