Skip to content

Handle missing GraphQL aliases as non-blocking repository skips - #68

Merged
rpothin merged 4 commits into
mainfrom
copilot/fix-graphql-response-alias-errors
May 18, 2026
Merged

Handle missing GraphQL aliases as non-blocking repository skips#68
rpothin merged 4 commits into
mainfrom
copilot/fix-graphql-response-alias-errors

Conversation

Copilot AI commented May 18, 2026

Copy link
Copy Markdown
Contributor

The TypeScript repository-details workflow was treating GraphQL batch responses that silently omit a repo alias as hard hydration failures. That blocked production runs when repositories disappeared between search indexing and detail hydration (for example, deleted or newly private repos).

  • Reclassify absent GraphQL aliases

    • Tag the providers.ts error emitted for repoN aliases missing from the GraphQL response with isMissingAlias: true.
    • This preserves the existing error surface while making the condition distinguishable from real hydration failures.
  • Track skipped repos separately in pipeline metrics

    • Extend PipelineMetrics with:
      • missingRepoSkips
      • missingRepoSkipNames
    • Add a narrow type guard for missing-alias errors so generator logic can branch without weakening other error handling.
  • Route missing aliases away from detailFailures

    • In the batch hydration path, handle isMissingAlias before PAT-policy classification.
    • Missing aliases now:
      • increment missingRepoSkips
      • record the repo name
      • emit a warning
      • skip the repo from output
    • They no longer inflate detailFailures.
  • Keep the production guard strict on real failures only

    • Update the workflow guard to emit a ::warning:: for missingRepoSkips instead of adding them to blockingFailures.
    • detailFailures remains the production-blocking signal for true structural hydration problems.
  • Add focused regression coverage

    • Verify provider-side missing-alias errors carry isMissingAlias: true.
    • Verify generator-side handling records a missing-repo skip, leaves detailFailures at zero, and excludes the vanished repo from output.

Example of the new provider tagging:

result.set(
  repo.fullName,
  Object.assign(
    new Error(`GraphQL response missing alias '${alias}' for ${repo.fullName}`),
    { isMissingAlias: true as const }
  )
);
Original prompt

Background

During the 1-update-github-repositories-details workflow, the TypeScript pipeline makes batched GraphQL calls (20 repos per batch). Each repo gets an alias (repo0repo19). When a repo has been deleted or made private after the search API indexed it, GitHub's GraphQL API silently omits the alias from the response — with no accompanying error. This causes the code in Pipeline/src/providers.ts (~L306) to record a "GraphQL response missing alias 'repoN' for owner/repo" error.

These errors are counted as detailFailures in PipelineMetrics. The production guard in the workflow (Guard TypeScript repository-count delta step) blocks the entire run whenever detailFailures > 0:

if (failures > 0) {
  blockingFailures.push(`TypeScript pipeline had ${failures} repository detail hydration failure(s); all must succeed in production live mode`);
}

This causes valid runs to fail when repos simply disappear from GitHub between the search and the detail-hydration phase.


Goal

Implement Option A: classify "missing alias" errors as a separate non-blocking metric (missingRepoSkips) so the production guard does not block on repos that have simply vanished.


Required Changes

1. Pipeline/src/providers.ts

When recording the "missing alias" error (the else if (node === undefined) branch, ~L306), tag the error so callers can distinguish it from a true hydration failure:

result.set(
  repo.fullName,
  Object.assign(
    new Error(`GraphQL response missing alias '${alias}' for ${repo.fullName}`),
    { isMissingAlias: true as const }
  )
);

2. Pipeline/src/types.ts

Add a new counter to PipelineMetrics:

missingRepoSkips: number;       // repos silently dropped from GraphQL response (deleted/private)
missingRepoSkipNames: string[]; // names of those repos

Also add a helper type / type-guard if appropriate.

3. Pipeline/src/generator.ts

In the batch hydration path (where result instanceof Error is checked), add a branch before the isPatPolicyError check to handle isMissingAlias:

if ((result as any).isMissingAlias) {
  metrics.missingRepoSkips += 1;
  metrics.missingRepoSkipNames.push(repository.fullName);
  metrics.warnings.push(`Skipping '${repository.fullName}' because it is no longer accessible (GraphQL alias absent): ${result.message}`);
  return null;
}

Make sure missingRepoSkips and missingRepoSkipNames are initialised to 0 / [] in createMetrics().

4. .github/workflows/update-github-repositories-details.yml

In the "Guard TypeScript repository-count delta" step, add a non-blocking informational log for missingRepoSkips, and ensure the hard-block only fires on detailFailures (true structural failures), not missingRepoSkips. Something like:

const missingRepoSkips = metrics.missingRepoSkips ?? 0;
if (missingRepoSkips > 0) {
  const names = (metrics.missingRepoSkipNames ?? []).join(', ');
  console.log(`::warning::TypeScript pipeline skipped ${missingRepoSkips} repo(s) whose GraphQL alias was absent (likely deleted/private). Affected: ${names}`);
}

The existing detailFailures block should remain unchanged — it still blocks if there are genuine hydration errors.

5. Pipeline/tests/providers.test.ts

The existing test "records a missing-alias error for an absent alias in the GraphQL response with no errors" should still pass — the error value it checks just now carries the extra isMissingAlias property, so no test changes are needed there. However, add a test that verifies the tagged property is present:

expect((r as any).isMissingAlias).toBe(true);

6. Pipeline/tests/generator.test.ts

Add a test for the new branch:

  • A batch provider that returns an error with isMissingAlias: true for one repo
  • Assert metrics.missingRepoSkips === 1
  • Assert metrics.detailFailures === 0
  • Assert the repo is absent from the output

Acceptance Criteria

  • isMissingAlias: true is set on the error recorded in providers.ts for the absent-alias case
  • PipelineMetrics has missingRepoSkips: number and missingRepoSkipNames: string[]
  • Generator routes isMissingAlias errors to missingRepoSkips, not detailFailures
  • Workflow guard emits a ::warning:: (not ::error::) for missingRepoSkips > 0 and does not add it to blockingFailures
  • All existing tests pass
  • New unit tests cover the isMissingAlias path in both provider and generator

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Investigate, explain and propose a plan to fix the error in the following github workflow run: https://github.com/rpothin/PowerPlatform-OpenSource-Hub/actions/runs/26032659964/job/76522433000

Assistant: Here's a full breakdown of what happened, why it failed, and how to fix it.


🔍 What Failed

The wor...

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Fix GraphQL response missing alias errors in TypeScript pipeline Handle missing GraphQL aliases as non-blocking repository skips May 18, 2026
Copilot AI requested a review from rpothin May 18, 2026 12:42
@rpothin
rpothin marked this pull request as ready for review May 18, 2026 19:23
@rpothin
rpothin merged commit 020efe2 into main May 18, 2026
4 checks passed
@rpothin
rpothin deleted the copilot/fix-graphql-response-alias-errors branch May 18, 2026 19:25
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.

2 participants