Skip to content

feat(forge): add Forgejo/Gitea forge.Client - #9522

Closed
MrGeek0s wants to merge 1 commit into
fullsend-ai:mainfrom
MrGeek0s:feature/Forgejo-API-Client
Closed

MrGeek0s wants to merge 1 commit into
fullsend-ai:mainfrom
MrGeek0s:feature/Forgejo-API-Client

Conversation

@MrGeek0s

Copy link
Copy Markdown

Summary

  • Adds internal/forge/forgejo implementing forge.Client for Forgejo/Gitea API v1 (core REST + high-value methods; remaining GitLab/Actions workflow methods return ErrNotSupported).
  • Extends DetectForge for Forgejo/Gitea hosts (including git.forge.internal).
  • Wires CLI newForgeClient("forgejo") via FORGEJO_TOKEN / GITEA_TOKEN, and accepts forgejo as a harness/repos forge key.

Developed and validated against a private Forgejo instance in the ForgeOps lab; unit tests included.

Test plan

  • go test ./internal/forge/forgejo/
  • go test ./internal/forge/ -run TestDetectForge
  • go test ./internal/cli/ -run TestNewForgeClient_Forgejo
  • Reviewer: live smoke against a Forgejo/Gitea instance with FORGEJO_TOKEN (-tags live_forgejo)

Introduce internal/forge/forgejo with core REST plus high-value methods
(forks, commits, PR reviews, comments, branch protection, Actions secrets),
DetectForge recognition for Forgejo hosts, and CLI/harness/repos wiring.

Co-authored-by: Cursor <cursoragent@cursor.com>
@MrGeek0s
MrGeek0s requested a review from a team as a code owner November 16, 2026 03:17
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Add Forgejo/Gitea client and forge selection support

✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Add a Forgejo/Gitea API v1 client for repository, issue, pull request, and selected administrative
 operations.
• Recognize Forgejo hosts and wire CLI token and URL configuration for the new forge key.
• Document unsupported operations and add unit tests plus an opt-in live smoke test.
Diagram

graph TD
  A["Git remotes"] --> B["Forge detection"] --> C["CLI client factory"] --> D["Forgejo adapter"] --> E["Forgejo API"]
  F["Forge keys"] --> C
  D -->|implements| G["forge.Client"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use a Forgejo/Gitea API SDK
  • ➕ Reduces hand-written HTTP and response mapping
  • ➕ May simplify API compatibility maintenance
  • ➖ Adds a dependency
  • ➖ Still requires translation into the broad forge.Client interface
2. Expose smaller capability interfaces
  • ➕ Lets callers distinguish supported operations without relying on runtime stubs
  • ➕ Avoids implying full Forgejo parity
  • ➖ Requires a broader change to existing forge-agnostic callers
  • ➖ Increases scope beyond adding one adapter

Recommendation: The adapter is the pragmatic fit for the existing forge.Client architecture. Keep its MVP scope explicit: sequential file writes are not atomic, many interface methods remain unsupported, and live API compatibility needs the planned smoke review. Smaller capability interfaces are worth considering separately if callers begin depending on Forgejo parity.

Files changed (16) +1765 / -8

Enhancement (8) +1557 / -8
forge_client.goConstruct Forgejo clients from CLI configuration +35/-3

Construct Forgejo clients from CLI configuration

• Adds Forgejo token resolution with FORGEJO_TOKEN preferred over GITEA_TOKEN. Selects an explicit API URL before Forgejo and Gitea environment fallbacks when constructing the client.

internal/cli/forge_client.go

detect.goRecognize Forgejo and Gitea remote hosts +7/-1

Recognize Forgejo and Gitea remote hosts

• Maps several known hosts and hostnames containing forgejo or gitea to the forgejo key.

internal/forge/detect.go

client.goAdd the Forgejo HTTP client foundation +227/-0

Add the Forgejo HTTP client foundation

• Introduces the forge.Client implementation, API base normalization, authenticated JSON requests, response decoding, and error mapping. Implements user and core repository operations.

internal/forge/forgejo/client.go

highvalue.goAdd selected fork, review, protection, and secret operations +436/-0

Add selected fork, review, protection, and secret operations

• Implements higher-value forge.Client methods for forks, sequential file commits, comments, pull request reviews, branch protection reads, and repository Actions secrets. Cross-repository proposals use an owner-and-branch head.

internal/forge/forgejo/highvalue.go

repos.goMap core repository, content, issue, and PR APIs +515/-0

Map core repository, content, issue, and PR APIs

• Implements file contents and branches alongside pull request, issue, label, comment, and commit-comparison operations. Translates API responses into shared forge types.

internal/forge/forgejo/repos.go

stubs.goExplicitly reject unmapped forge operations +329/-0

Explicitly reject unmapped forge operations

• Completes the shared interface with ErrNotSupported returns for operations including workflows, pipelines, variables, reactions, and hooks.

internal/forge/forgejo/stubs.go

forge.goAccept forgejo as a harness forge key +2/-0

Accept forgejo as a harness forge key

• Adds forgejo to the harness's recognized forge platform keys.

internal/harness/forge.go

manifest.goDefine and accept the forgejo forge key +6/-4

Define and accept the forgejo forge key

• Adds the forgejo constant and includes it in forge-name validation. The manifest's platform sections remain GitHub and GitLab.

internal/repos/manifest.go

Tests (6) +169 / -0
forge_client_test.goTest Forgejo CLI client creation +20/-0

Test Forgejo CLI client creation

• Checks client type and normalized base URL when a token is present, and the error returned when neither token variable is set.

internal/cli/forge_client_test.go

detect_test.goCover internal Forgejo remote detection +5/-0

Cover internal Forgejo remote detection

• Adds a test case for an HTTPS remote on git.forge.internal.

internal/forge/detect_test.go

client_test.goTest core client behavior and an unsupported operation +55/-0

Test core client behavior and an unsupported operation

• Uses an HTTP test server to exercise user and repository reads. Confirms that a pipeline operation returns ErrNotSupported.

internal/forge/forgejo/client_test.go

highvalue_test.goExercise selected high-value API methods +55/-0

Exercise selected high-value API methods

• Uses a mock HTTP server to test a branch file commit, pull request review creation and listing, and a protected-branch read.

internal/forge/forgejo/highvalue_test.go

live_smoke_test.goAdd opt-in Forgejo instance smoke test +33/-0

Add opt-in Forgejo instance smoke test

• Adds a live_forgejo-tagged test for authentication, repository lookup, and organization repository listing. It skips when FORGEJO_TOKEN is absent.

internal/forge/forgejo/live_smoke_test.go

harness_test.goTest harness recognition of forgejo +1/-0

Test harness recognition of forgejo

• Extends forge platform validation coverage to include forgejo.

internal/harness/harness_test.go

Documentation (1) +36 / -0
README.mdDocument Forgejo client setup and scope +36/-0

Document Forgejo client setup and scope

• Describes token and URL settings, supported operation groups, unsupported methods, non-goals, and the opt-in live smoke command.

internal/forge/forgejo/README.md

Other (1) +3 / -0
forge_config.goSelect GitHub-style workflow paths for Forgejo +3/-0

Select GitHub-style workflow paths for Forgejo

• Returns the GitHub forge configuration for forgejo, reusing its Actions shim paths and reference patterns.

internal/repos/forge_config.go

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

Grey Divider


Action required

1. The harness test suite fails 🐞 Bug ≡ Correctness
Description
Adding forgejo to validForgeKeys changes the sorted valid-key list, but
TestValidateForge_UnknownKey still asserts the old error text. Every run of that test now expects
a substring that the validator can no longer produce.
Code

internal/harness/forge.go[51]

Evidence
ForgeKeyList sorts the keys before composing the error, while the unchanged assertion requires
valid: github, gitlab, jira.

internal/harness/forge.go[50-52]
internal/harness/forge.go[86-91]
internal/harness/forge_test.go[493-498]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new forge key changes a validator error asserted by an existing test.
## Fix Focus Areas
- internal/harness/forge.go[50-52]
- internal/harness/forge_test.go[493-498]
## Recommended Fix
Update the assertion to include forgejo in sorted order and run the full harness test suite.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


2. Forgejo runs enter GitHub integrations 🐞 Bug ≡ Correctness
Description
The new harness key permits forgePlatform to become forgejo, but the run path selects GitHub
clients and status handling for every non-GitLab value. A Forgejo-selected run therefore reaches
GitHub credential minting, playback, and status paths instead of receiving an unsupported-platform
error or Forgejo handling.
Code

internal/harness/forge.go[51]

Evidence
Runtime platform detection now accepts the key; playback and status selection only distinguish
GitLab from the GitHub default, and the identity resolver rejects non-GitHub forges.

internal/harness/forge.go[50-52]
internal/cli/run.go[6988-7012]
internal/cli/run.go[6964-6977]
internal/cli/run.go[7064-7069]
internal/botidentity/mint.go[168-170]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The newly accepted runtime platform falls through to GitHub-specific operations.
## Fix Focus Areas
- internal/harness/forge.go[50-52]
- internal/cli/run.go[6964-6977]
- internal/cli/run.go[7064-7069]
## Recommended Fix
Add explicit Forgejo handling at runtime platform switches, or reject Forgejo for run commands until its credential, playback, and status integrations are implemented.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


3. Multi-file writes can leave partial changes 🐞 Bug ☼ Reliability
Description
CommitFilesToBranch and DeleteFiles implement multi-file operations as separate contents
requests rather than one atomic commit. If a later request fails, earlier files have already
changed, contrary to the shared contract used by delivery.
Code

internal/forge/forgejo/highvalue.go[R140-143]

Evidence
Both methods loop over individual file requests and return after a failure; the interface specifies
atomic multi-file commits and deletions.

internal/forge/forgejo/highvalue.go[111-123]
internal/forge/forgejo/highvalue.go[135-168]
internal/forge/forge.go[1150-1152]
internal/forge/forge.go[1174-1200]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Sequential requests expose partially completed multi-file changes.
## Fix Focus Areas
- internal/forge/forgejo/highvalue.go[111-123]
- internal/forge/forgejo/highvalue.go[126-168]
## Recommended Fix
Use Forgejo's batch commit or Git-tree facilities to apply each requested set in one commit; do not advertise these methods as successful atomic operations when a partial write is possible.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


View high (4)
4. New files fail to be created 🐞 Bug ≡ Correctness
Description
CreateFile calls putFile, which always sends PUT to the contents endpoint. Forgejo's contents
API uses POST to create a file and PUT to update one, so a missing file cannot be created
through this method.
Code

internal/forge/forgejo/repos.go[R109-112]

Evidence
CreateFile supplies an empty SHA to a helper hardcoded to PUT; create-or-update methods also use
that helper when lookup does not find a file.

internal/forge/forgejo/repos.go[93-112]
internal/forge/forgejo/repos.go[114-135]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The file-create method uses the update HTTP method.
## Fix Focus Areas
- internal/forge/forgejo/repos.go[93-135]
## Recommended Fix
Send POST for creates and PUT with the current SHA for updates; select the method after the existence check in create-or-update methods and verify both paths against API-shaped tests.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


5. Approvals are saved as pending drafts 🐞 Bug ≡ Correctness
Description
CreatePullRequestReview accepts the shared client’s APPROVE event but sends it unchanged to
Forgejo, whose approval event is APPROVED. When the review agent submits an approval, Gitea treats
the unrecognised value as a PENDING review, leaving an unpublished draft instead of approving the PR
and returning no error.
Code

internal/forge/forgejo/highvalue.go[R280-287]

Evidence
The shared client and its caller use APPROVE, while Forgejo’s create-review API lists APPROVED,
PENDING, COMMENT, REQUEST_CHANGES and REQUEST_REVIEW as allowed event values. Because APPROVE is
absent from that list, passing it through cannot request an approval, even though the local server
test accepts it.

internal/forge/forgejo/highvalue.go[279-305]
internal/forge/forgejo/highvalue.go[279-288]
internal/cli/postreview.go[590-601]
🌐 event ReviewStateType, Allowed values: APPROVED PENDING COMMENT REQUEST_CHANGES REQUEST_REVIEW
🌐 ReviewStateApproved ReviewStateType = "APPROVED"

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The shared approval event is `APPROVE`, but Forgejo expects `APPROVED`; Gitea saves an unrecognised event as a pending review.

## Fix Focus Areas
- internal/forge/forgejo/highvalue.go[279-288]
- internal/forge/forgejo/highvalue_test.go[44-46]

## Recommended Fix
Keep validating and accepting the shared GitHub-style events. Translate `APPROVE` to `APPROVED` for `payload["event"]`, while passing `REQUEST_CHANGES` and `COMMENT` through unchanged. Add a test that asserts the outgoing JSON event in the request body.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


6. Fetching an issue that is a PR fails 🐞 Bug ≡ Correctness
Description
apiIssue.Pull is declared as bool with tag json:"pull_request", but Forgejo returns
pull_request as an object (PullRequestMeta) when the issue is a PR. json.Unmarshal therefore
fails with "cannot unmarshal object into bool", so GetIssue returns a decode error for every PR
number, and IsPullRequest can never be true.
Code

internal/forge/forgejo/repos.go[395]

Evidence
do() returns a decode error whenever unmarshalling fails (client.go 104-107). GetIssue sets
IsPullRequest: iss.Pull and expects the field to decode for PRs. Gitea's Issue struct has
PullRequest *PullRequestMeta there, which is an object.

internal/forge/forgejo/repos.go[389-419]
internal/forge/forgejo/client.go[104-108]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`pull_request` is an object in Forgejo's issue payload, not a bool, so decoding fails for PRs.

## Fix Focus Areas
- internal/forge/forgejo/repos.go[389-397]
- internal/forge/forgejo/repos.go[418-418]
- internal/forge/forgejo/repos.go[440-440]

## Recommended Fix
Change the field to `Pull *struct{ Merged bool `json:"merged"` } `json:"pull_request"``, use `iss.Pull != nil` to tell whether it is a PR, and add a test whose fixture has a PR payload.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


7. Forgejo agents fail before launch 🔗 Cross-repo conflict ≡ Correctness
Description
validForgeKeys now accepts forgejo, but fullsend-ai/agents has no Forgejo harness configuration
to supply forge credentials and FULLSEND_FORGE, and its pre-scripts support only GitHub and
GitLab. When an agents code or review harness is selected with --forge forgejo, its pre-script
fails before the sandbox can run or use the new client.
Code

internal/harness/forge.go[51]

Evidence
The PR permits Forgejo as a harness platform. The agents harnesses configure only GitHub and GitLab,
while their pre-scripts require or dispatch on those forge-specific values.

fullsend -> agents
internal/harness/forge.go[43-55]
internal/cli/run.go[6988-7003]
External repo: fullsend-ai/agents, harness/code.yaml [113-177]
External repo: fullsend-ai/agents, harness/review.yaml [105-164]
External repo: fullsend-ai/agents, scripts/pre-review.src.sh [18-29]
External repo: fullsend-ai/agents, scripts/lib/review-ops.lib.sh [12-23]
External repo: fullsend-ai/agents, scripts/pre-code.sh [1658-1664]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The platform accepts Forgejo for agent runs, but the agents repository has no Forgejo harness configuration and its pre-scripts reject that forge.

## Fix Focus Areas
- internal/harness/forge.go[50-51]
- /cross_repos/agents/harness/code.yaml[113-177]
- /cross_repos/agents/harness/review.yaml[105-164]
- /cross_repos/agents/scripts/lib/review-ops.lib.sh[12-23]
- /cross_repos/agents/scripts/pre-code.sh[1658-1664]

## Recommended Fix
Add Forgejo overlays, credentials, and script dispatch in fullsend-ai/agents before enabling its harness key in fullsend, or defer accepting that key until the agents integration is ready.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗



Remediation recommended

8. Default Forgejo endpoint points at an internal host 📘 Rule violation ⛨ Security
Description
New initializes baseURL to the literal internal host https://git.forge.internal instead of
requiring a configured URL; the same host also appears in detect.go, the README and tests. When
newForgeClient receives neither a manifest URL nor FORGEJO_API_URL or GITEA_API_URL, requests
use that host and attach FORGEJO_TOKEN or GITEA_TOKEN in the Authorization header.
Code

internal/forge/forgejo/client.go[R53-54]

Evidence
The default base URL is a literal *.internal hostname in production code. The CLI adds
WithBaseURL only when a URL is configured, leaving that default in place otherwise, and do()
attaches the token to each request.

Rule 1062040: Disallow hardcoded secrets and sensitive environment-specific identifiers in source code
internal/forge/forgejo/client.go[53-54]
internal/cli/forge_client.go[72-88]
internal/forge/forgejo/client.go[74-81]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The Forgejo client defaults to a hardcoded internal hostname. When no manifest or environment URL is configured, requests use that host with the configured token.

## Fix Focus Areas
- internal/forge/forgejo/client.go[49-60]
- internal/cli/forge_client.go[77-88]

## Recommended Fix
Remove the literal default from `New` and set the base URL only from an explicit `WithBaseURL` option or an environment-derived value. In `newForgeClient`, return an error such as `set FORGEJO_API_URL or forge.url` when neither a manifest base URL nor `FORGEJO_API_URL` / `GITEA_API_URL` provides one. Remove the internal host from production logic, including `detect.go`, and update the README; use a placeholder such as `forge.example.com` in documentation and keep any internal-host examples confined to test fixtures.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


9. Internal Forgejo host hardcoded in forge detection 📘 Rule violation ⛨ Security
Description
DetectForge maps the exact hostname git.forge.internal to the forgejo forge, so the
organization's internal host is recognized by literal name in shipped logic. Any repository whose
remote is on that private host is classified by this hardcoded entry, which must be changed in code
whenever the internal host changes.
Code

internal/forge/detect.go[28]

Evidence
Rule 1062040 treats internal hostnames as red flags in source code, and the PR adds
git.forge.internal to a production switch statement. The rule's allowed list covers generic names
like localhost or example.com, not a private *.internal host.

Rule 1062040: Disallow hardcoded secrets and sensitive environment-specific identifiers in source code
internal/forge/detect.go[28-28]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`DetectForge` hardcodes `git.forge.internal` as a Forgejo host. This is an environment-specific internal hostname in source code.

## Fix Focus Areas
- internal/forge/detect.go[25-35]

## Recommended Fix
Remove `git.forge.internal` from the `case` list. Rely on the existing substring match for `forgejo`/`gitea`, or accept an operator-supplied host list via config or `--forge`, so that no private hostname is shipped in code.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


10. New Forgejo branch helper has untested dead code paths 📘 Rule violation ▣ Testability
Description
CreateBranchFromSHA builds and then overwrites a payload map that is never sent, and its
fallback path to the /branches endpoint is not exercised by any test. Several other new exported
methods in repos.go (such as CreateChangeProposal, CreateIssue, DeleteFile) are also not
referenced by any test in the package, so regressions in this code would pass go test unnoticed.
Code

internal/forge/forgejo/repos.go[R237-241]

Evidence
Rule 1062049 requires that tests reference the new or changed functions and logic paths. repos.go
adds about 500 lines of logic, but the only test file, client_test.go, exercises
GetAuthenticatedUser, GetRepo, and an unsupported stub, and highvalue_test.go exercises only
commit, review, and branch protection. CreateBranchFromSHA has a fallback and a double assignment
that no test covers.

Rule 1062049: Require tests for new or modified Go logic
internal/forge/forgejo/repos.go[237-241]
internal/forge/forgejo/client_test.go[13-55]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
New logic in `internal/forge/forgejo/repos.go` (notably `CreateBranchFromSHA`, `CreateChangeProposal`, `CreateIssue`, `DeleteFile`) has no test that references it, and `CreateBranchFromSHA` contains a dead `payload` assignment that is overwritten before use.

## Fix Focus Areas
- internal/forge/forgejo/repos.go[237-258]
- internal/forge/forgejo/client_test.go[1-55]

## Recommended Fix
Remove the dead first `payload` assignment in `CreateBranchFromSHA`. Add httptest-based tests that call `CreateBranchFromSHA` (both the `/git/refs` success path and the `/branches` fallback), `CreateChangeProposal`, `CreateIssue`, and `DeleteFile`, each asserting on the returned value or the request.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


View medium (16)
11. Misaligned review payload fails gofmt formatting 📘 Rule violation ✧ Quality
Description
The map literal in CreatePullRequestReview pads "event": and "body": with extra spaces that
gofmt would not produce, so the file is not canonically formatted. A gofmt-based lint step in `make
lint` would report this file and fail the change.
Code

internal/forge/forgejo/highvalue.go[R285-288]

Evidence
Rule 1062039 requires make lint to pass without failures for every change. The key-value alignment
inside payload := map[string]any{...} does not match gofmt output, so any formatting check
configured in the lint target flags this new file.

Rule 1062039: All code changes must pass make lint without failures
internal/forge/forgejo/highvalue.go[285-288]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new file `internal/forge/forgejo/highvalue.go` has misaligned map literal and struct field spacing in several places, including the payload in `CreatePullRequestReview`, which gofmt would rewrite. The lint target may fail on this.

## Fix Focus Areas
- internal/forge/forgejo/highvalue.go[285-288]
- internal/forge/forgejo/highvalue.go[249-255]

## Recommended Fix
Run `gofmt -w internal/forge/forgejo/*.go` and confirm `make lint` exits 0 before merge.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


12. Forgejo setup variables are undocumented 📘 Rule violation ⚙ Maintainability
Description
The PR adds the FORGEJO_TOKEN, GITEA_TOKEN, FORGEJO_API_URL and GITEA_API_URL environment
variables, read in newForgeClient, and registers forgejo as an accepted forge key, but no file
under docs/cli/ or docs/guides/ mentions any of them. The only token documentation in those
folders covers GitHub and GitLab (docs/cli/README.md line 42, docs/cli/repos.md line 15), so a
user installing against a Forgejo host has no documented variable to set and no documented --forge
value to use.
Code

internal/cli/forge_client.go[R32-35]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

Issue description
The PR adds Forgejo support to the CLI (`FORGEJO_TOKEN`, `GITEA_TOKEN`, `FORGEJO_API_URL`, `GITEA_API_URL`, and the `forgejo` forge key), but `docs/cli/README.md` and `docs/cli/repos.md` only describe GitHub and GitLab. Users have no documented way to authenticate or point the CLI at a Forgejo host.

Fix Focus Areas
- internal/cli/forge_client.go[32-35]
- internal/repos/manifest.go[36-39]
- docs/cli/README.md[42]
- docs/cli/repos.md[15]

Recommended Fix
In `docs/cli/README.md`, extend the token-resolution paragraph to list `FORGEJO_TOKEN` then `GITEA_TOKEN` for Forgejo, and note that `FORGEJO_API_URL` or `GITEA_API_URL` overrides the default host. In `docs/cli/repos.md`, add `forgejo` to the list of accepted forge values and state that the `--forge` flag accepts it. Keep the wording consistent with the existing GitLab entries.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


13. Unchanged files create unnecessary commits 🐞 Bug ≡ Correctness
Description
CommitFilesToBranch writes every non-deleted file and sets changed to true without comparing its
content to the current version. Repeating the same delivery therefore makes another commit rather
than returning (false, nil) as callers expect for an unchanged batch.
Code

internal/forge/forgejo/highvalue.go[R162-165]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Repeated identical batches are reported and written as changes.
## Fix Focus Areas
- internal/forge/forgejo/highvalue.go[135-168]
## Recommended Fix
Compare proposed bytes and mode with existing branch entries before constructing the batch, skip identical files, and return false without committing when no entries differ.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


14. Missing files cannot be conditionally created 🐞 Bug ≡ Correctness
Description
UpdateFileIfMatch immediately returns the lookup's not-found error rather than treating an empty
expectedSHA as permission to create the absent file. Callers using its conditional-create contract
cannot initialize a missing path, while a missing path with a nonempty expected SHA is not reported
as a conflict.
Code

internal/forge/forgejo/highvalue.go[R101-106]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Conditional writes return not-found instead of handling missing files according to the expected SHA.
## Fix Focus Areas
- internal/forge/forgejo/highvalue.go[99-109]
## Recommended Fix
On a missing file, create only when expectedSHA is empty; otherwise return ErrConflict. Preserve a single write attempt and conflict handling for races.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


15. Nested directory entries disappear 🐞 Bug ≡ Correctness
Description
ListDirectoryContents discards its recursive argument and returns only one contents response. A
caller requesting recursive entries cannot see files and directories below immediate children.
Code

internal/forge/forgejo/repos.go[R150-152]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Recursive directory requests return only the first level.
## Fix Focus Areas
- internal/forge/forgejo/repos.go[149-172]
## Recommended Fix
When recursive is true, walk child directories and return flattened paths relative to the requested directory while propagating traversal errors.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


16. Large trees look complete when they are not 🐞 Bug ≡ Correctness
Description
ListRepositoryFiles decodes the tree's truncated flag but never checks it before returning paths
and a nil error. When Forgejo truncates a large tree, callers treat missing paths as absent instead
of taking the documented per-path fallback.
Code

internal/forge/forgejo/repos.go[186]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
An incomplete tree response is returned as a successful full listing.
## Fix Focus Areas
- internal/forge/forgejo/repos.go[181-199]
## Recommended Fix
Check the decoded truncated flag and return an error wrapping forge.ErrTreeTruncated instead of a partial list.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


17. Some file paths target the wrong resource 🐞 Bug ≡ Correctness
Description
The contents methods append file paths to request URLs without escaping URL-significant characters.
A valid repository filename containing ? or # is interpreted as a query or fragment instead of
part of the file path, affecting reads and writes.
Code

internal/forge/forgejo/repos.go[R54-57]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Raw file paths can change the URL's query or fragment.
## Fix Focus Areas
- internal/forge/forgejo/repos.go[54-60]
- internal/forge/forgejo/repos.go[93-105]
- internal/forge/forgejo/repos.go[137-155]
- internal/forge/forgejo/highvalue.go[150-153]
## Recommended Fix
Encode each file-path segment while preserving directory separators, and use that helper consistently for contents reads, writes, listings, and deletions.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


18. Named references fail to resolve 🐞 Bug ≡ Correctness
Description
GetRef strips only refs/heads/ before passing its argument to the branch endpoint. The
interface's documented heads/main form is therefore requested as a branch literally named
heads/main, producing not-found for an existing main branch.
Code

internal/forge/forgejo/repos.go[R219-221]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The ref adapter treats documented ref paths as literal branch names.
## Fix Focus Areas
- internal/forge/forgejo/repos.go[218-222]
## Recommended Fix
Normalize `heads/` and `refs/heads/` paths before branch lookup, and handle tag references through the appropriate tag endpoint rather than a branch lookup.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


19. Existing forks can break delivery 🐞 Bug ☼ Reliability
Description
CreateFork always sends a create request and returns its error without first checking for an
existing fork. A repeated request or a fork created between delivery's lookup and creation fails
instead of returning the existing fork as the interface promises.
Code

internal/forge/forgejo/highvalue.go[R55-59]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Fork creation does not satisfy the shared idempotency contract.
## Fix Focus Areas
- internal/forge/forgejo/highvalue.go[15-60]
## Recommended Fix
Check for an existing fork and, on an existing-fork response or creation race, retrieve and return its verified metadata rather than failing.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


20. Fork lookup failures masquerade as absence 🐞 Bug ☼ Reliability
Description
FindExistingFork ignores errors from its second repository GET and falls through to the empty,
nil-error result. If that request fails after the first response identified a fork, delivery treats
an unverified state as no fork and attempts creation.
Code

internal/forge/forgejo/highvalue.go[R42-46]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A failed verification request is reported as no existing fork.
## Fix Focus Areas
- internal/forge/forgejo/highvalue.go[15-51]
## Recommended Fix
Decode parent information in the first repository request or propagate errors from the second request; reserve empty values with nil error for a confirmed missing fork.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


21. Forced commits do not reset history 🐞 Bug ≡ Correctness
Description
ForceCommitFileToBranch simply calls CreateOrUpdateFileOnBranch, which updates a file on the
branch's existing history. Callers expecting the documented root-based, history-pruning operation
instead get an ordinary commit, and a missing target branch is not created.
Code

internal/forge/forgejo/highvalue.go[R170-173]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The method performs a normal file update rather than its destructive forced-commit contract.
## Fix Focus Areas
- internal/forge/forgejo/highvalue.go[170-173]
## Recommended Fix
Return ErrNotSupported until Forgejo can implement root-based commit creation, branch creation, and history pruning with the required skip-CI message behavior.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


22. Issues created with labels are rejected 🐞 Bug ≡ Correctness
Description
CreateIssue forwards label names into the request’s labels field, but Forgejo/Gitea’s
CreateIssueOption.labels requires numeric label IDs. When callers pass labels, the server returns
a 422 or JSON binding error and does not create the issue; the separate add-label endpoint accepts
names.
Code

internal/forge/forgejo/repos.go[R401-404]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Creating an issue with labels sends label names to a field that requires numeric IDs, causing the request to fail.

## Fix Focus Areas
- internal/forge/forgejo/repos.go[399-410]

## Recommended Fix
Either create the issue without labels and then call `AddIssueLabels(ctx, owner, repo, iss.Number, labels...)`, since that endpoint accepts names, or resolve or create the requested labels first and send their numeric IDs in the create-issue payload. Existing labels can be resolved via `GET /repos/{o}/{r}/labels`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


23. Commit comparison never reports ancestry 🐞 Bug ≡ Correctness
Description
CompareCommits reads a top-level status field that Forgejo’s compare response does not provide,
so it returns "unknown" instead of a commit relationship. Even when the comparison succeeds,
RefResolver.IsAncestor and the fork-fallback check in layers/commit.go reject that value because
they require ahead or identical, disrupting upgrade/downgrade detection and fork delivery.
Code

internal/forge/forgejo/repos.go[R511-514]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Forgejo’s compare response has no top-level `status` field, so `CompareCommits` returns `unknown` even for successful comparisons, and consumers cannot recognize ancestor or identical relationships.

## Fix Focus Areas
- internal/forge/forgejo/repos.go[501-515]
- internal/layers/commit.go[549-559]

## Recommended Fix
Decode `total_commits` from both base...head and head...base comparisons, following the GitLab implementation. Return `identical` when base equals head or both counts are zero, `ahead` when only the forward count is positive, `behind` when only the reverse count is positive, and `diverged` when both are positive. Test each relationship using Forgejo-shaped responses.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


24. Scope preflight blocks every Forgejo token 🐞 Bug ≡ Correctness
Description
GetTokenScopes returns the made-up scope ["all"] instead of nil, although the interface says to
return nil when the forge can't report scopes. layers/preflight.go then compares the required
scopes (e.g. repo, workflow) against {"all"}, reports every one as missing, and blocks
operations that should be skipped with a fine-grained/unknown-scopes result.
Code

internal/forge/forgejo/client.go[R160-166]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Returning `["all"]` makes preflight report every required scope as missing.

## Fix Focus Areas
- internal/forge/forgejo/client.go[159-166]

## Recommended Fix
After the auth probe succeeds, `return nil, nil` so callers skip scope validation, as the interface documents.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


25. Listings silently drop items past page one 🐞 Bug ≡ Correctness
Description
ListOrgRepos, ListRepoPullRequests, ListOpenIssues, ListPullRequestCommits,
ListPullRequestFiles/FileDiffs, and ListIssueComments each decode one response from a request
with a fixed limit and never fetch another page. When a collection exceeds its first page—50 items
by default under Forgejo’s MAX_RESPONSE_ITEMS cap—callers silently receive incomplete data,
including manifest glob expansion and file diffs used to place inline review comments.
Code

internal/forge/forgejo/client.go[R171-174]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Forgejo list methods fetch only their first response page. With a default page-size cap of 50, larger collections are silently truncated for callers.

## Fix Focus Areas
- internal/forge/forgejo/client.go[168-186]
- internal/forge/forgejo/repos.go[319-330]
- internal/forge/forgejo/repos.go[367-379]
- internal/forge/forgejo/repos.go[428-446]
- internal/forge/forgejo/repos.go[488-499]
- internal/forge/forgejo/highvalue.go[232-276]
- internal/forge/forgejo/highvalue.go[308-334]

## Recommended Fix
Add a reusable pagination helper for these list methods that requests successive pages with `limit=50`, combines their results, and stops when the server indicates there are no further results, using a short page or the absence of `Link: rel="next"` as applicable. Add tests with collections exceeding one page.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


26. Wildcard-protected branches read as unprotected 🐞 Bug ≡ Correctness
Description
GetProtectedBranch calls /branch_protections/{branch}, but Forgejo looks this endpoint up by
rule name, not by the branch it matches. A branch covered by a glob rule such as release/*, or by
a rule with a different name, gets a 404 and is reported as unprotected via return nil, nil.
Code

internal/forge/forgejo/highvalue.go[R369-375]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The branch_protections/{name} endpoint is keyed by rule name, so branches protected by a glob rule are reported as unprotected.

## Fix Focus Areas
- internal/forge/forgejo/highvalue.go[352-382]

## Recommended Fix
Call GET /repos/{o}/{r}/branches/{branch} and use its `protected` field. Alternatively, list the rules and match the branch against each rule's glob. Return nil only when no rule matches.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗



Informational

27. Label errors are swallowed or missed 🐞 Bug ☼ Reliability
Description
EnsureLabel looks for "409" in err.Error(), but do() maps 409 to forge.ErrConflict, whose
message is just "conflict", so that branch never matches. The 422/already substring check also
swallows unrelated validation failures and any error whose URL path happens to contain "422", and
AddIssueLabels discards EnsureLabel errors entirely.
Code

internal/forge/forgejo/repos.go[R452-458]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
EnsureLabel tells failures apart by matching substrings of the error text, which misses 409 and swallows unrelated 422 errors.

## Fix Focus Areas
- internal/forge/forgejo/repos.go[449-470]

## Recommended Fix
GET the repo's labels and skip creation when the name already exists. For create errors, use `forge.IsConflict(err)` rather than string matching. Return or log the errors in AddIssueLabels instead of discarding them.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


28. Stub comments name the wrong methods 🐞 Bug ⚙ Maintainability
Description
Several doc comments in stubs.go describe a different method than the one below them, e.g.
"FindExistingFork is not yet implemented" above DeleteProjectServiceAccount, and
"IsProtectedBranch is not yet implemented" above ListProtectedTags, even though those named
methods are implemented in highvalue.go. CreateBranchFromSHA also builds two payload maps that
are never sent, so a later reader can't tell which methods are real and which request is actually
made.
Code

internal/forge/forgejo/stubs.go[R11-12]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The stub doc comments name the wrong methods, and CreateBranchFromSHA has dead assignments.

## Fix Focus Areas
- internal/forge/forgejo/stubs.go[11-26]
- internal/forge/forgejo/stubs.go[116-162]
- internal/forge/forgejo/stubs.go[206-207]
- internal/forge/forgejo/repos.go[238-246]

## Recommended Fix
Rename each comment so it matches the function below it. In CreateBranchFromSHA, remove the unused `payload` assignments.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


Grey Divider

⚠️ Warning | Comment size exceeded, inner finding content trimmed View findings
⚠️ Warning | Comment size exceeded, non finding content trimmed Learn more

Grey Divider

Qodo Logo

Comment on lines +53 to +54
token: token,
baseURL: normalizeAPIBase("https://git.forge.internal"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

8. Default forgejo endpoint points at an internal host 📘 Rule violation ⛨ Security

New initializes baseURL to the literal internal host https://git.forge.internal instead of
requiring a configured URL; the same host also appears in detect.go, the README and tests. When
newForgeClient receives neither a manifest URL nor FORGEJO_API_URL or GITEA_API_URL, requests
use that host and attach FORGEJO_TOKEN or GITEA_TOKEN in the Authorization header.
Agent Prompt
## Issue description
The Forgejo client defaults to a hardcoded internal hostname. When no manifest or environment URL is configured, requests use that host with the configured token.

## Fix Focus Areas
- internal/forge/forgejo/client.go[49-60]
- internal/cli/forge_client.go[77-88]

## Recommended Fix
Remove the literal default from `New` and set the base URL only from an explicit `WithBaseURL` option or an environment-derived value. In `newForgeClient`, return an error such as `set FORGEJO_API_URL or forge.url` when neither a manifest base URL nor `FORGEJO_API_URL` / `GITEA_API_URL` provides one. Remove the internal host from production logic, including `detect.go`, and update the README; use a placeholder such as `forge.example.com` in documentation and keep any internal-host examples confined to test fixtures.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment thread internal/forge/detect.go
return "github", nil
case "gitlab.com":
return "gitlab", nil
case "git.forge.internal", "codeberg.org", "gitea.com":

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

9. Internal forgejo host hardcoded in forge detection 📘 Rule violation ⛨ Security

DetectForge maps the exact hostname git.forge.internal to the forgejo forge, so the
organization's internal host is recognized by literal name in shipped logic. Any repository whose
remote is on that private host is classified by this hardcoded entry, which must be changed in code
whenever the internal host changes.
Agent Prompt
## Issue description
`DetectForge` hardcodes `git.forge.internal` as a Forgejo host. This is an environment-specific internal hostname in source code.

## Fix Focus Areas
- internal/forge/detect.go[25-35]

## Recommended Fix
Remove `git.forge.internal` from the `case` list. Rely on the existing substring match for `forgejo`/`gitea`, or accept an operator-supplied host list via config or `--forge`, so that no private hostname is shipped in code.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment on lines +237 to +241
// CreateBranchFromSHA implements forge.Client.
func (c *LiveClient) CreateBranchFromSHA(ctx context.Context, owner, repo, branch, sha string) error {
payload := map[string]any{"new_branch_name": branch, "old_ref_name": sha}
// Forgejo: POST /repos/{owner}/{repo}/branches
payload = map[string]any{"new_branch_name": branch, "old_branch_name": ""}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

10. New forgejo branch helper has untested dead code paths 📘 Rule violation ▣ Testability

CreateBranchFromSHA builds and then overwrites a payload map that is never sent, and its
fallback path to the /branches endpoint is not exercised by any test. Several other new exported
methods in repos.go (such as CreateChangeProposal, CreateIssue, DeleteFile) are also not
referenced by any test in the package, so regressions in this code would pass go test unnoticed.
Agent Prompt
## Issue description
New logic in `internal/forge/forgejo/repos.go` (notably `CreateBranchFromSHA`, `CreateChangeProposal`, `CreateIssue`, `DeleteFile`) has no test that references it, and `CreateBranchFromSHA` contains a dead `payload` assignment that is overwritten before use.

## Fix Focus Areas
- internal/forge/forgejo/repos.go[237-258]
- internal/forge/forgejo/client_test.go[1-55]

## Recommended Fix
Remove the dead first `payload` assignment in `CreateBranchFromSHA`. Add httptest-based tests that call `CreateBranchFromSHA` (both the `/git/refs` success path and the `/branches` fallback), `CreateChangeProposal`, `CreateIssue`, and `DeleteFile`, each asserting on the returned value or the request.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment on lines +285 to +288
payload := map[string]any{
"event": event,
"body": body,
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

11. Misaligned review payload fails gofmt formatting 📘 Rule violation ✧ Quality

The map literal in CreatePullRequestReview pads "event": and "body": with extra spaces that
gofmt would not produce, so the file is not canonically formatted. A gofmt-based lint step in `make
lint` would report this file and fail the change.
Agent Prompt
## Issue description
The new file `internal/forge/forgejo/highvalue.go` has misaligned map literal and struct field spacing in several places, including the payload in `CreatePullRequestReview`, which gofmt would rewrite. The lint target may fail on this.

## Fix Focus Areas
- internal/forge/forgejo/highvalue.go[285-288]
- internal/forge/forgejo/highvalue.go[249-255]

## Recommended Fix
Run `gofmt -w internal/forge/forgejo/*.go` and confirm `make lint` exits 0 before merge.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment on lines +32 to +35
if token := os.Getenv("FORGEJO_TOKEN"); token != "" {
return token, nil
}
if token := os.Getenv("GITEA_TOKEN"); token != "" {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

12. Forgejo setup variables are undocumented 📘 Rule violation ⚙ Maintainability

The PR adds the FORGEJO_TOKEN, GITEA_TOKEN, FORGEJO_API_URL and GITEA_API_URL environment
variables, read in newForgeClient, and registers forgejo as an accepted forge key, but no file
under docs/cli/ or docs/guides/ mentions any of them. The only token documentation in those
folders covers GitHub and GitLab (docs/cli/README.md line 42, docs/cli/repos.md line 15), so a
user installing against a Forgejo host has no documented variable to set and no documented --forge
value to use.
Agent Prompt
Issue description
The PR adds Forgejo support to the CLI (`FORGEJO_TOKEN`, `GITEA_TOKEN`, `FORGEJO_API_URL`, `GITEA_API_URL`, and the `forgejo` forge key), but `docs/cli/README.md` and `docs/cli/repos.md` only describe GitHub and GitLab. Users have no documented way to authenticate or point the CLI at a Forgejo host.

Fix Focus Areas
- internal/cli/forge_client.go[32-35]
- internal/repos/manifest.go[36-39]
- docs/cli/README.md[42]
- docs/cli/repos.md[15]

Recommended Fix
In `docs/cli/README.md`, extend the token-resolution paragraph to list `FORGEJO_TOKEN` then `GITEA_TOKEN` for Forgejo, and note that `FORGEJO_API_URL` or `GITEA_API_URL` overrides the default host. In `docs/cli/repos.md`, add `forgejo` to the list of accepted forge values and state that the `--forge` flag accepts it. Keep the wording consistent with the existing GitLab entries.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment on lines +171 to +174
path := "/orgs/" + url.PathEscape(org) + "/repos?limit=100"
if _, err := c.do(ctx, http.MethodGet, path, nil, &raw); err != nil {
return nil, err
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

25. Listings silently drop items past page one 🐞 Bug ≡ Correctness

ListOrgRepos, ListRepoPullRequests, ListOpenIssues, ListPullRequestCommits,
ListPullRequestFiles/FileDiffs, and ListIssueComments each decode one response from a request
with a fixed limit and never fetch another page. When a collection exceeds its first page—50 items
by default under Forgejo’s MAX_RESPONSE_ITEMS cap—callers silently receive incomplete data,
including manifest glob expansion and file diffs used to place inline review comments.
Agent Prompt
## Issue description
Forgejo list methods fetch only their first response page. With a default page-size cap of 50, larger collections are silently truncated for callers.

## Fix Focus Areas
- internal/forge/forgejo/client.go[168-186]
- internal/forge/forgejo/repos.go[319-330]
- internal/forge/forgejo/repos.go[367-379]
- internal/forge/forgejo/repos.go[428-446]
- internal/forge/forgejo/repos.go[488-499]
- internal/forge/forgejo/highvalue.go[232-276]
- internal/forge/forgejo/highvalue.go[308-334]

## Recommended Fix
Add a reusable pagination helper for these list methods that requests successive pages with `limit=50`, combines their results, and stops when the server indicates there are no further results, using a short page or the absence of `Link: rel="next"` as applicable. Add tests with collections exceeding one page.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment on lines +452 to +458
if err != nil && strings.Contains(err.Error(), "409") {
return nil
}
// already exists often returns 422
if err != nil && (strings.Contains(err.Error(), "422") || strings.Contains(strings.ToLower(err.Error()), "already")) {
return nil
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational

27. Label errors are swallowed or missed 🐞 Bug ☼ Reliability

EnsureLabel looks for "409" in err.Error(), but do() maps 409 to forge.ErrConflict, whose
message is just "conflict", so that branch never matches. The 422/already substring check also
swallows unrelated validation failures and any error whose URL path happens to contain "422", and
AddIssueLabels discards EnsureLabel errors entirely.
Agent Prompt
## Issue description
EnsureLabel tells failures apart by matching substrings of the error text, which misses 409 and swallows unrelated 422 errors.

## Fix Focus Areas
- internal/forge/forgejo/repos.go[449-470]

## Recommended Fix
GET the repo's labels and skip creation when the name already exists. For create errors, use `forge.IsConflict(err)` rather than string matching. Return or log the errors in AddIssueLabels instead of discarding them.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment on lines +369 to +375
p := "/repos/" + escapePath(owner, repo) + "/branch_protections/" + url.PathEscape(branch)
code, err := c.do(ctx, http.MethodGet, p, nil, &raw)
if err != nil {
if code == http.StatusNotFound || forge.IsNotFound(err) {
return nil, nil
}
return nil, err

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remediation recommended

26. Wildcard-protected branches read as unprotected 🐞 Bug ≡ Correctness

GetProtectedBranch calls /branch_protections/{branch}, but Forgejo looks this endpoint up by
rule name, not by the branch it matches. A branch covered by a glob rule such as release/*, or by
a rule with a different name, gets a 404 and is reported as unprotected via return nil, nil.
Agent Prompt
## Issue description
The branch_protections/{name} endpoint is keyed by rule name, so branches protected by a glob rule are reported as unprotected.

## Fix Focus Areas
- internal/forge/forgejo/highvalue.go[352-382]

## Recommended Fix
Call GET /repos/{o}/{r}/branches/{branch} and use its `protected` field. Alternatively, list the rules and match the branch against each rule's glob. Return nil only when no rule matches.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment on lines +11 to +12
// FindExistingFork is not yet implemented for Forgejo.
func (c *LiveClient) DeleteProjectServiceAccount(ctx context.Context, owner, repo string, userID int) error {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Informational

28. Stub comments name the wrong methods 🐞 Bug ⚙ Maintainability

Several doc comments in stubs.go describe a different method than the one below them, e.g.
"FindExistingFork is not yet implemented" above DeleteProjectServiceAccount, and
"IsProtectedBranch is not yet implemented" above ListProtectedTags, even though those named
methods are implemented in highvalue.go. CreateBranchFromSHA also builds two payload maps that
are never sent, so a later reader can't tell which methods are real and which request is actually
made.
Agent Prompt
## Issue description
The stub doc comments name the wrong methods, and CreateBranchFromSHA has dead assignments.

## Fix Focus Areas
- internal/forge/forgejo/stubs.go[11-26]
- internal/forge/forgejo/stubs.go[116-162]
- internal/forge/forgejo/stubs.go[206-207]
- internal/forge/forgejo/repos.go[238-246]

## Recommended Fix
Rename each comment so it matches the function below it. In CreateBranchFromSHA, remove the unused `payload` assignments.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

Comment thread internal/harness/forge.go
// abstraction design (see https://github.com/fullsend-ai/fullsend/pull/6237).
"jira": true,
// Forgejo/Gitea API client (ForgeOps FACTORY-FULLSEND-FORGEJO-CLIENT-001).
"forgejo": true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

7. Forgejo agents fail before launch 🔗 Cross-repo conflict ≡ Correctness

validForgeKeys now accepts forgejo, but fullsend-ai/agents has no Forgejo harness configuration
to supply forge credentials and FULLSEND_FORGE, and its pre-scripts support only GitHub and
GitLab. When an agents code or review harness is selected with --forge forgejo, its pre-script
fails before the sandbox can run or use the new client.
Agent Prompt
## Issue description
The platform accepts Forgejo for agent runs, but the agents repository has no Forgejo harness configuration and its pre-scripts reject that forge.

## Fix Focus Areas
- internal/harness/forge.go[50-51]
- /cross_repos/agents/harness/code.yaml[113-177]
- /cross_repos/agents/harness/review.yaml[105-164]
- /cross_repos/agents/scripts/lib/review-ops.lib.sh[12-23]
- /cross_repos/agents/scripts/pre-code.sh[1658-1664]

## Recommended Fix
Add Forgejo overlays, credentials, and script dispatch in fullsend-ai/agents before enabling its harness key in fullsend, or defer accepting that key until the agents integration is ready.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗

@github-actions github-actions Bot closed this Nov 16, 2026
@github-actions

Copy link
Copy Markdown

Thank you for your interest in contributing to fullsend, @MrGeek0s.

This project uses a vouch system for first-time contributors. Before submitting a pull request, you need to be vouched by a maintainer.

To get vouched:

  1. Open a Vouch Request discussion.
  2. Describe what you want to change and why.
  3. Write in your own words — do not have an AI generate the request.
  4. A maintainer will comment /vouch if approved.
  5. Once vouched, open a new PR (preferred) or reopen this one.

See CONTRIBUTING.md for details.

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