[Bugfix #749][Bugfix #750] Fix Gitea forge crash and field normalization#768
Merged
Conversation
Two tightly-coupled Gitea-forge regressions reported in v3.0.3: #749 — parseLabelDefaults() crashed with `labels.map is not a function`, 500ing the Tower overview when Forgejo returned `labels: ""` (or null) for unlabeled issues. Coerce non-array inputs to [] so the array methods can't throw. Added regression tests exercising the empty-string, null, and undefined paths alongside the existing array (GitHub) path. #750 — Tower showed `#undefined` / `NaNd` because the Gitea preset scripts piped raw `tea` JSON straight to the overview, which expects the GitHub-compatible shape declared in forge-contracts.ts. Each script now requests an explicit `--fields` list and normalizes via jq: index (string) -> number (int) created -> createdAt author (string) -> author.login labels (CSV) -> labels[].name assignees (CSV) -> assignees[].login description -> body recently-closed maps `updated` -> `closedAt`; recently-merged filters by `.merged == true` (same predicate gitea/pr-exists.sh already uses) and maps `updated` -> `mergedAt`, `head.ref` -> `headRefName`. Fixes #749 Fixes #750
The labels parameter type in parseLabelDefaults() was widened to accept `string | null | undefined` as part of the #749 fix, so the @ts-expect-error directives in the new regression tests no longer have anything to suppress. Per Gemini CMAP cosmetic note.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two tightly-coupled Gitea-forge regressions reported in v3.0.3 against a Forgejo instance, fixed together since the second was masked by the first (Tower 500'd before the rendering bug was visible).
#749 —
labels.map is not a function500 on Tower overviewForgejo/Gitea returns
labels: ""(ornull) for unlabeled issues, where GitHub always returns[].parseLabelDefaults()inlib/github.tscalled.map()unconditionally and crashed.[]before mapping:Array.isArray(labels) ? labels.map(...) : []Array<{name}> | null | undefined | stringto reflect the actual cross-forge runtime shape (the project's forge-contracts already document presets as "best-effort" with non-conforming shapes treated as nulls; this lifts the contract into the type system at one call site)#750 —
#undefined/NaNdin Tower overview for GiteaOnce the 500 was patched, every backlog row rendered
#undefinedand ages showedNaNdbecause the Gitea preset scripts piped rawtea --output jsonstraight to the overview, which expects the GitHub-compatible shape declared inforge-contracts.ts.Each of the four affected scripts now requests an explicit
--fieldslist and normalizes viajq:teafieldindex(string)number(int)createdcreatedAtauthor(flat string)author.loginlabels(CSV string or"")labels[].nameassignees(CSV string or"")assignees[].logindescriptionbodyrecently-closed.sh: mapsupdated→closedAt(Gitea has noclosed_atfield on list output; for issues edited after close this overestimates, acceptable for the 24h overview window)recently-merged.sh: filtersselect(.merged == true)(same predicatescripts/forge/gitea/pr-exists.shalready uses) and mapsupdated→mergedAt,head.ref→headRefNamejqis already a runtime dependency of the gitea preset (pr-exists.sh,user-identity.shboth use it) so this introduces no new tooling requirement.Test plan
pnpm exec vitest run src/__tests__/github.test.ts→ 55/55 pass (4 new regression cases)pnpm exec tsc --noEmitcleanIssueListItem/PrListItemshapes inforge-contracts.tsFixes #749
Fixes #750