Clear remaining low-risk review debt on the release branch
The PR still had a few targeted review threads around contributor pagination, route-layer passthroughs, dead header fallbacks, and synthetic response ids. These are small enough to settle directly on the release branch without broadening the merge scope, and they tighten the repo back toward the service-owned boundaries this refactor is aiming for. Constraint: Keep the changes narrow and regression-covered so the release PR stays green while review threads are closed out Rejected: Leave the minor threads for follow-up after merge | they were isolated enough to fix now and would keep noise on the PR Confidence: high Scope-risk: narrow Directive: When a route shim stops serving any route-local behavior, point callers at the owning service instead of keeping a passthrough around Tested: Focused vitest for contributor updater, openai responses response bridge, upstream request builder, stats proxy logs, architecture boundaries; typecheck; repo drift check; git diff --check Not-tested: Full npm test; unresolved review threads that still require larger product decisions
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
parsePaginatedJson,
|
||||
normalizeContributors,
|
||||
replaceContributorsSection,
|
||||
renderContributorsBlock,
|
||||
@@ -108,4 +109,11 @@ describe('README contributors updater', () => {
|
||||
expect(html).toContain('\n <a href="https://github.com/Babylonehy"');
|
||||
expect((html.match(/\n <a href=/g) || []).length).toBe(2);
|
||||
});
|
||||
|
||||
it('parses concatenated paginated gh api arrays without requiring newlines between pages', () => {
|
||||
expect(parsePaginatedJson('[{"login":"a"}][{"login":"b"}]')).toEqual([
|
||||
{ login: 'a' },
|
||||
{ login: 'b' },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -127,9 +127,28 @@ export function fetchContributors(repo = REPO): ReadmeContributor[] {
|
||||
return normalizeContributors(parsePaginatedJson(raw) as GitHubContributor[]);
|
||||
}
|
||||
|
||||
function parsePaginatedJson(raw: string): unknown[] {
|
||||
export function parsePaginatedJson(raw: string): unknown[] {
|
||||
const trimmedRaw = raw.trim();
|
||||
if (!trimmedRaw) return [];
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(trimmedRaw);
|
||||
return Array.isArray(parsed) ? parsed : [parsed];
|
||||
} catch {
|
||||
// Fall through to paginated-array parsing.
|
||||
}
|
||||
|
||||
try {
|
||||
const mergedArrays = JSON.parse(`[${trimmedRaw.replace(/\]\s*\[/g, '],[')}]`);
|
||||
if (Array.isArray(mergedArrays)) {
|
||||
return mergedArrays.flatMap((item) => (Array.isArray(item) ? item : [item]));
|
||||
}
|
||||
} catch {
|
||||
// Fall through to line-by-line parsing.
|
||||
}
|
||||
|
||||
const items: unknown[] = [];
|
||||
for (const line of raw.split('\n')) {
|
||||
for (const line of trimmedRaw.split('\n')) {
|
||||
const trimmed = line.trim();
|
||||
if (!trimmed) {
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user