feat(catalog): add scheduled Forgejo discovery #51

Merged
martin merged 4 commits from feat/forgejo-discovery-24 into main 2026-11-21 18:37:02 +00:00
Owner

Summary

  • Replace startup-only repository sync with a scheduled Forgejo entity provider.
  • Treat each repository's catalog-info.yaml as the sole source of its catalog metadata; repositories without one are omitted.
  • Remove the central enrichment map and generated snapshot exporter.
  • Preserve the last successful descriptor snapshot on refresh failures and reconcile removals after successful refreshes.
  • Document the design in docs/forgejo-discovery.md and docs/decisions/001-forgejo-catalog-source-of-truth.md.

Refs #24

Validation

  • bun install --frozen-lockfile
  • bun run tsc
  • bun run lint:all
  • bun run prettier:check
  • bun run build:backend
  • CI=1 bun run test:ci --runInBand (10 tests)
  • Backstage config validation for the E2E overlay

E2E was not run locally because a pre-existing backend process occupies the configured localhost port; it was left untouched. Woodpecker PR pipeline #137 is running on the current head.

## Summary - Replace startup-only repository sync with a scheduled Forgejo entity provider. - Treat each repository's `catalog-info.yaml` as the sole source of its catalog metadata; repositories without one are omitted. - Remove the central enrichment map and generated snapshot exporter. - Preserve the last successful descriptor snapshot on refresh failures and reconcile removals after successful refreshes. - Document the design in `docs/forgejo-discovery.md` and `docs/decisions/001-forgejo-catalog-source-of-truth.md`. Refs #24 ## Validation - `bun install --frozen-lockfile` - `bun run tsc` - `bun run lint:all` - `bun run prettier:check` - `bun run build:backend` - `CI=1 bun run test:ci --runInBand` (10 tests) - Backstage config validation for the E2E overlay E2E was not run locally because a pre-existing backend process occupies the configured localhost port; it was left untouched. Woodpecker PR pipeline #137 is running on the current head.
feat(catalog): add scheduled Forgejo discovery
Some checks failed
ci/woodpecker/pr/pr-review Pipeline was successful
ci/woodpecker/pr/application-checks Pipeline failed
9018a72c22
Replace startup-only repository sync with a scheduled entity provider, preserving descriptor precedence and last-good catalog state on refresh failures. Document configuration and behavior.

Co-authored-by: OpenCode <opencode@anoma.ly>
fix(e2e): resolve config paths from package workspaces
All checks were successful
ci/woodpecker/pr/pr-review Pipeline was successful
ci/woodpecker/pr/application-checks Pipeline was successful
166f89c207
Use paths relative to the app and backend package roots when Playwright starts the Backstage workspaces.

Co-authored-by: OpenCode <opencode@anoma.ly>
refactor(catalog): trust repository descriptors for discovery
Some checks failed
ci/woodpecker/pr/pr-review Pipeline was successful
ci/woodpecker/pr/application-checks Pipeline was canceled
585b71cbbc
Remove central repository enrichment and the generated catalog snapshot workflow. Import only repositories with catalog-info.yaml so repository metadata remains the source of truth.

Co-authored-by: OpenCode <opencode@anoma.ly>
docs(catalog): record descriptor source-of-truth decision
All checks were successful
ci/woodpecker/pr/application-checks Pipeline was successful
ci/woodpecker/pr/pr-review Pipeline was successful
ebfefdb853
Document repository-owned catalog metadata as the authoritative source and link the decision from the discovery guide.

Co-authored-by: OpenCode <opencode@anoma.ly>
Member

Objective

  • Review PR #51 (feat(catalog): add scheduled Forgejo discovery) in Personal/backstage for bugs, security, performance, code quality, and best practices.
  • Output ONLY a raw JSON object matching the given schema (summary, verdict, comments[]), no markdown fences, no extra text; language: English.

Important Details

  • Review style: balanced; must not repeat findings already covered by PR context (prior review by clank-bot exists; discussion notes Gitea integration, all-or-nothing refresh semantics).
  • Verdict choices: approve / changes / comment; severity choices: bug / security / performance / style; comments need file, line, side (new/old, omit for new files), severity, message; empty comments: [] if no new issues.
  • Repo root: /woodpecker/src/code.martials.no/Personal/backstage; diff at /woodpecker/src/code.martials.no/Personal/backstage/.tmp5UbAab/pr.diff (50KB cap per read; read with offset/limit; earlier reads: lines 1–542, 543–1743 region, 1743+ region — diff lines ~1743–2443+ covered, but lines ~1200–1743 gap exists and may not have been read).
  • Environment constraints: bash tool broken (NotFound: ChildProcess.spawn for any command incl. echo ok); glob/rg (ripgrep) failing; node_modules absent (cannot inspect installed packages); directory reads via read tool work; webfetch to raw.githubusercontent.com and api.github.com works (404s = wrong paths, search/code API = 401).
  • Verified facts:
    • @backstage/config ConfigReader.getOptionalBoolean coerces strings "true"/"false"/"y"/"yes"/"1"/"on" → enabled: ${FORGEJO_DISCOVERY_ENABLED:-true} works (NOT a bug).
    • Config file merge: higher-priority (later --config) values win; objects deep-merge, arrays from later config fully REPLACE earlier arrays → E2E overlay's catalog.locations replaces base's, enabled: false merges correctly.
    • Fixtures exist: packages/app/e2e-tests/fixtures/catalog/ contains forgejo-repos.yaml, org.yaml, services.yaml, systems.yaml.
    • GiteaUrlReader exists in @backstage/backend-defaults entrypoints/urlReader/lib/GiteaUrlReader.ts, included in UrlReaders.default; predicate = url.host === integration.config.host; converts .../src/branch/<ref>/<path> → /api/v1/repos/<owner>/<name>/contents/<path>?ref=<ref> with integration credentials → Location target format is correct.
    • readGiteaConfig trims trailing slashes from baseUrl; parseGiteaUrl uses url.replace(baseUrl, '') — breaks if html_url host ≠ configured integration host (FORGEJO_URL vs server ROOT_URL mismatch); edge case, likely not worth flagging.
    • Backstage threat model: entities emitted directly by an entity provider are trusted (rules not applied); entities from provider-emitted Locations (repository descriptors) ARE subject to catalog.rules = allow: [Component, System, API, Resource, Location] in app-config.yaml (per-location rules on org.yaml for User/Group).
    • Scheduler: SchedulerServiceTaskConfig supports optional initialDelay; whether task runs immediately at startup (without initialDelay) is still unverified — README/AGENTS claim "at startup and every 15 minutes".
  • Candidate findings to finalize (not yet reported):
    • Pagination loop in listRepositories breaks on batch.length < pageSize; silently truncates if server caps limit below 50 (old sync script had same pattern; Gitea honors limit ≤ 50) — possible low-severity robustness note; alternative termination: break on empty batch.
    • Location target built from API-provided html_url without validating host matches integration host (SSRF/hardening suggestion; mirrors built-in providers).
    • Mismatch: descriptor check uses no ref when default_branch empty, Location target hardcodes 'main' fallback (minor).
    • hasCatalogDescriptor treats any 200 as present (no content check) — minor.
    • readDuration: frequencyCron silently takes precedence over minutes/seconds if both present — minor.
    • Concurrency 5 fixed, not configurable; N+1 descriptor checks per refresh — acceptable perf, possible note.
    • Playwright webServer.command paths (--config ../../app-config.yaml, --config e2e-tests/app-config.yaml, --config ../app/e2e-tests/app-config.yaml) assume backstage-cli repo start sets child cwd to package dir — consistent with Backstage docs (--config ../../app-config.yaml pattern) but not 100% verified; CI E2E (Woodpecker pipeline #137) will exercise it since CI sets webServer: [] only when CI env set — actually CI path sets webServer: [], so verify how CI starts servers before flagging.
  • Local tool failures to work around: no shell, no ripgrep; use read for files/dirs, webfetch/websearch for upstream source.

Work State

Completed

  • Read full PR diff head (lines 1–542) and later portions (1743+); reviewed key changes: new provider ForgejoEntityProvider.ts, module.ts, tests, app-config.yaml provider block, removal of examples/forgejo-repos.yaml, scripts/sync-forgejo-catalog.mjs, sync:forgejo script, @backstage/plugin-catalog-backend-module-gitea dep removal, octokit lockfile churn, new docs docs/forgejo-discovery.md, docs/decisions/001-forgejo-catalog-source-of-truth.md.
  • Verified packages/backend/package.json dependency additions (@backstage/backend-plugin-api, @backstage/integration, @backstage/plugin-catalog-node, @backstage/types) via bun.lock diff.
  • Confirmed env-string boolean coercion, multi-config array/object merge semantics, fixture file presence, GiteaUrlReader availability and URL format, readGiteaConfig trailing-slash trim, catalog.rules interaction with provider-emitted entities.
  • Read working-tree playwright.config.ts, package.json, .woodpecker/application-checks.yaml, app-config.yaml (working tree = PR head).

Active

  • Investigating whether the scheduler runs the task immediately at startup (no initialDelay) — last fetch: packages/backend-defaults/src/entrypoints/scheduler/lib/TaskWorker.ts (retrieved but not yet analyzed for first-run timing).
  • About to consolidate findings into the required JSON review output.

Blocked

  • Diff lines ~1200–1743 (mid-portion: docs/forgejo-discovery.md tail, examples/forgejo-repos.yaml deletion, package.json, packages/app/e2e-tests/app-config.yaml, packages/backend/package.json, provider TS source start) not yet read — provider implementation details (listRepositories, hasCatalogDescriptor, mapConcurrent, locationSpecToLocationEntity usage, readProviderConfigs) need direct line numbers for comments.
  • No shell/node_modules: cannot run tests or inspect installed package source locally.
  • Upstream TaskWorker first-run behavior unresolved; GitHub code search API unavailable (401).

Next Move

  1. Read the unread diff region (offset ~1200, limit ~550) of /woodpecker/src/code.martials.no/Personal/backstage/.tmp5UbAab/pr.diff to capture exact provider source line numbers (needed for comments[].line on ForgejoEntityProvider.ts).
  2. Finish scheduler first-run check (fetch TaskWorker.ts executeOnce/start logic or search docs), then decide final findings (pagination truncation robustness, html_url host validation, default_branch/'main' mismatch, cron-vs-duration precedence) and emit the single raw JSON object with verdict (likely approve or comment given balanced style unless a real bug surfaces).

Relevant Files

  • /woodpecker/src/code.martials.no/Personal/backstage/.tmp5UbAab/pr.diff: the PR diff under review; read in chunks with offset/limit; gap at ~1200–1743.
  • packages/backend/src/catalog/forgejo/ForgejoEntityProvider.ts: core new provider; primary target for correctness findings; need exact line numbers from diff.
  • packages/backend/src/catalog/forgejo/ForgejoEntityProvider.test.ts: test coverage (timeout, reconciliation, disabled provider).
  • packages/backend/src/catalog/forgejo/module.ts, packages/backend/src/index.ts: plugin registration via catalogProcessingExtensionPoint.
  • app-config.yaml: integrations.gitea.baseUrl: ${FORGEJO_URL:-https://code.martials.no}, catalog.providers.forgejo.main block, catalog.rules: [Component, System, API, Resource, Location].
  • packages/app/e2e-tests/app-config.yaml + playwright.config.ts: E2E overlay (enabled: false, replacement catalog.locations) and webServer commands with relative --config paths.
  • docs/forgejo-discovery.md, docs/decisions/001-forgejo-catalog-source-of-truth.md: new docs referenced by README/AGENTS.
  • bun.lock, package.json, .woodpecker/application-checks.yaml, .prettierignore: supporting changes (dep swap, lockfile octokit churn, CI path-exclude removal).
    Continue if you have next steps, or stop and ask for clarification if you are unsure how to proceed.
    Now reading the unread middle portion of the PR diff to capture exact provider line numbers.
    Now verifying the scheduler's first-run behavior (docs claim a refresh at startup).
    Re-checking the new docs for accuracy against the verified implementation.
    Verifying one critical detail: how getGiteaRequestOptions treats an empty password (app-config uses ${FORGEJO_TOKEN:-}).
    Final verification of the exact line numbers in the new provider file before writing the review.
    {"summary":"Replaces the static Forgejo catalog sync script with a scheduled backend entity provider: ForgejoEntityProvider lists configured user/organization repositories through the Gitea integration (paginated, bounded-concurrency descriptor checks), emits a full-snapshot Location set only for repositories containing catalog-info.yaml, and keeps the last successful catalog whenever a non-404 error, malformed response, or timeout occurs. The change also swaps the built-in gitea module for local wiring, adds thorough unit tests plus an E2E overlay that disables live discovery and loads fixture catalogs, and documents the design in docs/forgejo-discovery.md and an ADR. I verified the env-string boolean coercion of FORGEJO_DISCOVERY_ENABLED, multi-config merge semantics (overlay arrays replace, booleans merge), scheduler startup behavior (duration cadence without initialDelay runs immediately, so the docs' "refreshes at startup" claim holds), Playwright --config path resolution against upstream cli-module-build sources (config paths resolve relative to each package dir), GiteaUrlReader compatibility of the src/branch/ target format, empty-password behavior in getGiteaRequestOptions (public requests stay unauthenticated as documented), and the accuracy of the docs' claims about the built-in Gitea provider. Remaining findings are non-blocking robustness and hardening suggestions.","verdict":"approve","comments":[{"file":"packages/backend/src/catalog/forgejo/ForgejoEntityProvider.ts","line":341,"severity":"bug","message":"Pagination ends whenever a page returns fewer than pageSize items, but a Forgejo instance that caps limit below 50 (e.g. a lowered API.MAX_RESULT_LIMIT) yields a short first page, silently dropping every subsequent repository - and because refresh then submits a full mutation, those repositories' locations are removed from the catalog. Conversely, a server that ignores the page parameter never terminates this loop, since the scheduler's task AbortSignal is not propagated to fetch. Break on an empty batch with a generous page cap instead; that costs one extra request per owner per refresh but handles both cases."},{"file":"packages/backend/src/catalog/forgejo/ForgejoEntityProvider.ts","line":255,"severity":"security","message":"The Location target is built from the API-supplied html_url without checking that its host matches the configured integration. If Forgejo's ROOT_URL differs from FORGEJO_URL, the target host fails GiteaUrlReader's predicate (url.host === integration host), so it falls through to the generic unauthenticated fetcher; the same applies to an off-host html_url returned by a non-conforming server. Build the target from integration.config.baseUrl plus owner/name (as apiBaseUrl already does) and reject repositories whose html_url host does not match the provider host."},{"file":"packages/backend/src/catalog/forgejo/ForgejoEntityProvider.ts","line":149,"severity":"performance","message":"When one descriptor check rejects, Promise.all rejects and refresh fails, but the other workers keep draining the remaining queue and issuing requests whose results are discarded. On a large owner set a failed refresh can therefore continue hitting requestTimeoutSeconds long after the error was recorded; a shared stop flag (or the task AbortSignal) checked in the while loop would fail fast."},{"file":"packages/backend/src/catalog/forgejo/ForgejoEntityProvider.ts","line":74,"severity":"style","message":"frequencyCron silently takes precedence: a config like frequency: { cron: '...', minutes: 5 } drops the duration keys with no warning, and readProviderConfigs accepts either form. Throw when both cron and duration keys are present so the misconfiguration surfaces at startup instead of being silently ignored."}]}

*🤖 Review by opencode (opencode/mimo-v2.6-flash-free) — verdict: comment

## Objective - Review PR #51 (`feat(catalog): add scheduled Forgejo discovery`) in `Personal/backstage` for bugs, security, performance, code quality, and best practices. - Output ONLY a raw JSON object matching the given schema (`summary`, `verdict`, `comments[]`), no markdown fences, no extra text; language: English. ## Important Details - Review style: balanced; must not repeat findings already covered by PR context (prior review by clank-bot exists; discussion notes Gitea integration, all-or-nothing refresh semantics). - Verdict choices: `approve` / `changes` / `comment`; severity choices: `bug` / `security` / `performance` / `style`; comments need `file`, `line`, `side` (`new`/`old`, omit for new files), `severity`, `message`; empty `comments: []` if no new issues. - Repo root: `/woodpecker/src/code.martials.no/Personal/backstage`; diff at `/woodpecker/src/code.martials.no/Personal/backstage/.tmp5UbAab/pr.diff` (50KB cap per read; read with `offset`/`limit`; earlier reads: lines 1–542, 543–1743 region, 1743+ region — diff lines ~1743–2443+ covered, but lines ~1200–1743 gap exists and may not have been read). - Environment constraints: `bash` tool broken (`NotFound: ChildProcess.spawn` for any command incl. `echo ok`); `glob`/`rg` (ripgrep) failing; `node_modules` absent (cannot inspect installed packages); directory reads via `read` tool work; webfetch to `raw.githubusercontent.com` and `api.github.com` works (404s = wrong paths, `search/code` API = 401). - Verified facts: - `@backstage/config` `ConfigReader.getOptionalBoolean` coerces strings `"true"/"false"/"y"/"yes"/"1"/"on"` → `enabled: ${FORGEJO_DISCOVERY_ENABLED:-true}` works (NOT a bug). - Config file merge: higher-priority (later `--config`) values win; objects deep-merge, arrays from later config fully REPLACE earlier arrays → E2E overlay's `catalog.locations` replaces base's, `enabled: false` merges correctly. - Fixtures exist: `packages/app/e2e-tests/fixtures/catalog/` contains `forgejo-repos.yaml`, `org.yaml`, `services.yaml`, `systems.yaml`. - `GiteaUrlReader` exists in `@backstage/backend-defaults` `entrypoints/urlReader/lib/GiteaUrlReader.ts`, included in `UrlReaders.default`; predicate = `url.host === integration.config.host`; converts `.../src/branch/<ref>/<path>` → `/api/v1/repos/<owner>/<name>/contents/<path>?ref=<ref>` with integration credentials → Location target format is correct. - `readGiteaConfig` trims trailing slashes from `baseUrl`; `parseGiteaUrl` uses `url.replace(baseUrl, '')` — breaks if `html_url` host ≠ configured integration host (FORGEJO_URL vs server ROOT_URL mismatch); edge case, likely not worth flagging. - Backstage threat model: entities emitted directly by an entity provider are trusted (rules not applied); entities from provider-emitted Locations (repository descriptors) ARE subject to `catalog.rules` = `allow: [Component, System, API, Resource, Location]` in `app-config.yaml` (per-location rules on org.yaml for User/Group). - Scheduler: `SchedulerServiceTaskConfig` supports optional `initialDelay`; whether task runs immediately at startup (without `initialDelay`) is still unverified — README/AGENTS claim "at startup and every 15 minutes". - Candidate findings to finalize (not yet reported): - Pagination loop in `listRepositories` breaks on `batch.length < pageSize`; silently truncates if server caps `limit` below 50 (old sync script had same pattern; Gitea honors limit ≤ 50) — possible low-severity robustness note; alternative termination: break on empty batch. - Location target built from API-provided `html_url` without validating host matches integration host (SSRF/hardening suggestion; mirrors built-in providers). - Mismatch: descriptor check uses no `ref` when `default_branch` empty, Location target hardcodes `'main'` fallback (minor). - `hasCatalogDescriptor` treats any 200 as present (no content check) — minor. - `readDuration`: `frequencyCron` silently takes precedence over `minutes`/`seconds` if both present — minor. - Concurrency 5 fixed, not configurable; N+1 descriptor checks per refresh — acceptable perf, possible note. - Playwright `webServer.command` paths (`--config ../../app-config.yaml`, `--config e2e-tests/app-config.yaml`, `--config ../app/e2e-tests/app-config.yaml`) assume `backstage-cli repo start` sets child cwd to package dir — consistent with Backstage docs (`--config ../../app-config.yaml` pattern) but not 100% verified; CI E2E (Woodpecker pipeline #137) will exercise it since CI sets `webServer: []` only when `CI` env set — actually CI path sets `webServer: []`, so verify how CI starts servers before flagging. - Local tool failures to work around: no shell, no ripgrep; use `read` for files/dirs, webfetch/websearch for upstream source. ## Work State ### Completed - Read full PR diff head (lines 1–542) and later portions (1743+); reviewed key changes: new provider `ForgejoEntityProvider.ts`, `module.ts`, tests, `app-config.yaml` provider block, removal of `examples/forgejo-repos.yaml`, `scripts/sync-forgejo-catalog.mjs`, `sync:forgejo` script, `@backstage/plugin-catalog-backend-module-gitea` dep removal, octokit lockfile churn, new docs `docs/forgejo-discovery.md`, `docs/decisions/001-forgejo-catalog-source-of-truth.md`. - Verified `packages/backend/package.json` dependency additions (`@backstage/backend-plugin-api`, `@backstage/integration`, `@backstage/plugin-catalog-node`, `@backstage/types`) via bun.lock diff. - Confirmed env-string boolean coercion, multi-config array/object merge semantics, fixture file presence, GiteaUrlReader availability and URL format, `readGiteaConfig` trailing-slash trim, `catalog.rules` interaction with provider-emitted entities. - Read working-tree `playwright.config.ts`, `package.json`, `.woodpecker/application-checks.yaml`, `app-config.yaml` (working tree = PR head). ### Active - Investigating whether the scheduler runs the task immediately at startup (no `initialDelay`) — last fetch: `packages/backend-defaults/src/entrypoints/scheduler/lib/TaskWorker.ts` (retrieved but not yet analyzed for first-run timing). - About to consolidate findings into the required JSON review output. ### Blocked - Diff lines ~1200–1743 (mid-portion: `docs/forgejo-discovery.md` tail, `examples/forgejo-repos.yaml` deletion, `package.json`, `packages/app/e2e-tests/app-config.yaml`, `packages/backend/package.json`, provider TS source start) not yet read — provider implementation details (`listRepositories`, `hasCatalogDescriptor`, `mapConcurrent`, `locationSpecToLocationEntity` usage, `readProviderConfigs`) need direct line numbers for comments. - No shell/node_modules: cannot run tests or inspect installed package source locally. - Upstream `TaskWorker` first-run behavior unresolved; GitHub code search API unavailable (401). ## Next Move 1. Read the unread diff region (`offset` ~1200, `limit` ~550) of `/woodpecker/src/code.martials.no/Personal/backstage/.tmp5UbAab/pr.diff` to capture exact provider source line numbers (needed for `comments[].line` on `ForgejoEntityProvider.ts`). 2. Finish scheduler first-run check (fetch `TaskWorker.ts` `executeOnce`/`start` logic or search docs), then decide final findings (pagination truncation robustness, `html_url` host validation, `default_branch`/`'main'` mismatch, cron-vs-duration precedence) and emit the single raw JSON object with `verdict` (likely `approve` or `comment` given balanced style unless a real bug surfaces). ## Relevant Files - `/woodpecker/src/code.martials.no/Personal/backstage/.tmp5UbAab/pr.diff`: the PR diff under review; read in chunks with `offset`/`limit`; gap at ~1200–1743. - `packages/backend/src/catalog/forgejo/ForgejoEntityProvider.ts`: core new provider; primary target for correctness findings; need exact line numbers from diff. - `packages/backend/src/catalog/forgejo/ForgejoEntityProvider.test.ts`: test coverage (timeout, reconciliation, disabled provider). - `packages/backend/src/catalog/forgejo/module.ts`, `packages/backend/src/index.ts`: plugin registration via `catalogProcessingExtensionPoint`. - `app-config.yaml`: `integrations.gitea.baseUrl: ${FORGEJO_URL:-https://code.martials.no}`, `catalog.providers.forgejo.main` block, `catalog.rules: [Component, System, API, Resource, Location]`. - `packages/app/e2e-tests/app-config.yaml` + `playwright.config.ts`: E2E overlay (`enabled: false`, replacement `catalog.locations`) and webServer commands with relative `--config` paths. - `docs/forgejo-discovery.md`, `docs/decisions/001-forgejo-catalog-source-of-truth.md`: new docs referenced by README/AGENTS. - `bun.lock`, `package.json`, `.woodpecker/application-checks.yaml`, `.prettierignore`: supporting changes (dep swap, lockfile octokit churn, CI path-exclude removal). Continue if you have next steps, or stop and ask for clarification if you are unsure how to proceed. Now reading the unread middle portion of the PR diff to capture exact provider line numbers. Now verifying the scheduler's first-run behavior (docs claim a refresh at startup). Re-checking the new docs for accuracy against the verified implementation. Verifying one critical detail: how `getGiteaRequestOptions` treats an empty `password` (app-config uses `${FORGEJO_TOKEN:-}`). Final verification of the exact line numbers in the new provider file before writing the review. {"summary":"Replaces the static Forgejo catalog sync script with a scheduled backend entity provider: ForgejoEntityProvider lists configured user/organization repositories through the Gitea integration (paginated, bounded-concurrency descriptor checks), emits a full-snapshot Location set only for repositories containing catalog-info.yaml, and keeps the last successful catalog whenever a non-404 error, malformed response, or timeout occurs. The change also swaps the built-in gitea module for local wiring, adds thorough unit tests plus an E2E overlay that disables live discovery and loads fixture catalogs, and documents the design in docs/forgejo-discovery.md and an ADR. I verified the env-string boolean coercion of FORGEJO_DISCOVERY_ENABLED, multi-config merge semantics (overlay arrays replace, booleans merge), scheduler startup behavior (duration cadence without initialDelay runs immediately, so the docs' \"refreshes at startup\" claim holds), Playwright --config path resolution against upstream cli-module-build sources (config paths resolve relative to each package dir), GiteaUrlReader compatibility of the src/branch/<encoded-ref> target format, empty-password behavior in getGiteaRequestOptions (public requests stay unauthenticated as documented), and the accuracy of the docs' claims about the built-in Gitea provider. Remaining findings are non-blocking robustness and hardening suggestions.","verdict":"approve","comments":[{"file":"packages/backend/src/catalog/forgejo/ForgejoEntityProvider.ts","line":341,"severity":"bug","message":"Pagination ends whenever a page returns fewer than pageSize items, but a Forgejo instance that caps limit below 50 (e.g. a lowered API.MAX_RESULT_LIMIT) yields a short first page, silently dropping every subsequent repository - and because refresh then submits a full mutation, those repositories' locations are removed from the catalog. Conversely, a server that ignores the page parameter never terminates this loop, since the scheduler's task AbortSignal is not propagated to fetch. Break on an empty batch with a generous page cap instead; that costs one extra request per owner per refresh but handles both cases."},{"file":"packages/backend/src/catalog/forgejo/ForgejoEntityProvider.ts","line":255,"severity":"security","message":"The Location target is built from the API-supplied html_url without checking that its host matches the configured integration. If Forgejo's ROOT_URL differs from FORGEJO_URL, the target host fails GiteaUrlReader's predicate (url.host === integration host), so it falls through to the generic unauthenticated fetcher; the same applies to an off-host html_url returned by a non-conforming server. Build the target from integration.config.baseUrl plus owner/name (as apiBaseUrl already does) and reject repositories whose html_url host does not match the provider host."},{"file":"packages/backend/src/catalog/forgejo/ForgejoEntityProvider.ts","line":149,"severity":"performance","message":"When one descriptor check rejects, Promise.all rejects and refresh fails, but the other workers keep draining the remaining queue and issuing requests whose results are discarded. On a large owner set a failed refresh can therefore continue hitting requestTimeoutSeconds long after the error was recorded; a shared stop flag (or the task AbortSignal) checked in the while loop would fail fast."},{"file":"packages/backend/src/catalog/forgejo/ForgejoEntityProvider.ts","line":74,"severity":"style","message":"frequencyCron silently takes precedence: a config like frequency: { cron: '...', minutes: 5 } drops the duration keys with no warning, and readProviderConfigs accepts either form. Throw when both cron and duration keys are present so the misconfiguration surfaces at startup instead of being silently ignored."}]} --- *🤖 Review by opencode (opencode/mimo-v2.6-flash-free) — verdict: **comment** <!-- forgejo-opencode-review -->
martin merged commit f4cbb1d60a into main 2026-11-21 18:37:02 +00:00
martin deleted branch feat/forgejo-discovery-24 2026-11-21 18:37:03 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Personal/backstage!51
No description provided.