Skip to content

Improve diagnostics when Codex cross-link index fetch fails - #3894

Closed
reakaleek wants to merge 4 commits into
mainfrom
cursor/cross-link-fetch-errors
Closed

reakaleek wants to merge 4 commits into
mainfrom
cursor/cross-link-fetch-errors

Conversation

@reakaleek

Copy link
Copy Markdown
Member

Why

  • When the Elastic Internal Docs link index cannot be fetched, builds emit many per-link errors that do not explain the root cause.
  • Fork pull request jobs often fail because GitHub does not provide an OIDC token to clone elastic/codex-link-index.

What

  • Record cross-link fetch failures and emit one summary diagnostic from the docset configuration file.
  • Suppress per-link validation errors when the link index for that repository was not loaded.
  • Improve git clone failure messages for CI fork jobs and local development.

Notes

Made with Cursor

Co-authored-by: Cursor <cursoragent@cursor.com>
Tests of fetch-failure diagnostics already go through public APIs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@reakaleek
reakaleek marked this pull request as ready for review August 20, 2026 09:08
@reakaleek
reakaleek requested a review from a team as a code owner August 20, 2026 09:08
@reakaleek
reakaleek requested a review from theletterf August 20, 2026 09:08
@reakaleek

Copy link
Copy Markdown
Member Author

@copilot resolve the merge conflicts in this pull request

…ch-errors

# Conflicts:
#	src/Elastic.Documentation.LinkIndex/GitLinkIndexReader.cs
#	src/Elastic.Documentation.Links/CrossLinks/DocSetConfigurationCrossLinkFetcher.cs

Co-authored-by: reakaleek <16325797+reakaleek@users.noreply.github.com>

Copilot AI commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

@copilot resolve the merge conflicts in this pull request

Resolved — I merged main into this branch, fixed the conflicts, and pushed the merge commit ae4896e7.

@github-actions

Copy link
Copy Markdown
Contributor

Docs preview (local build)

Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/3894/

Comment on lines +16 to +19
if (crossLinks.FetchFailures.Count == 0)
return;

collector.EmitError(configurationPath, FormatSummary(crossLinks));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P3 (Low)

This emits a hard error for every entry in FetchFailures, even when no page in the docset links to that repository. Before this change, a failed or missing link index for a declared cross_links repo only logged a warning, and errors appeared only when an actual cross-link failed to resolve. Now any declared repo that is missing from the link index or can't be fetched fails the build, including repos that are listed but unused, repos not yet published to the index, and transient S3/codex outages. Consider emitting the summary only when at least one cross-link to a failed repo was encountered, or downgrading it to a warning when nothing references the repo.

Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.

Comment on lines +26 to +31
var isCodexFailure = repositories.All(repository =>
crossLinks.RegistryByRepository?.GetValueOrDefault(repository) is { } registry
&& registry != DocSetRegistry.Public);
var distinctReasons = fetchFailures.Values.Distinct(StringComparer.Ordinal).ToArray();
var heading = isCodexFailure && distinctReasons.Length == 1
? $"Could not fetch the Elastic Internal Docs link index from {CodexLinkIndexUrl}."

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P3 (Low)

isCodexFailure is computed from each entry's declared Registry, not from the reader that was actually used. When useDualRegistry is false (no codex reader, or the docset registry is Public), non-public entries are fetched from the public S3 reader. If that fetch fails, the summary still says "Could not fetch the Elastic Internal Docs link index from https://github.com/elastic/codex-link-index", which sends users toward the wrong root cause. Use crossLinks.CodexRepositories (the repos actually routed to the codex reader) instead.

Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.

Comment on lines +74 to +75
if (fetchedCrossLinks.FetchFailures.ContainsKey(crossLinkUri.Scheme))
return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P3 (Low)

Preserve incremental-build invalidation when suppressing these diagnostics. Failed resolution leaves the original repository-scheme URL in rendered HTML, but no longer marks the containing Markdown file as offending. The summary marks only docset.yml, so a subsequent local build skips unchanged Markdown even after index access is repaired and can succeed with broken links still in its output. Track affected files separately or invalidate generation state whenever a fetch is incomplete.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

Comment on lines +14 to +39
public class CrossLinkFetchFailureTests(ITestOutputHelper output)
{
[Fact]
public void TryResolve_WhenFetchFailed_DoesNotEmitPerLinkError()
{
var crossLinks = BuildCrossLinksWithFetchFailure("synthetics-service", "Git clone failed: auth error");

string? emittedError = null;
var resolver = new IsolatedBuildEnvironmentUriResolver();
var success = CrossLinkResolver.TryResolve(
s => emittedError = s,
crossLinks,
resolver,
new Uri("synthetics-service://index.md", UriKind.Absolute),
out _
);

success.Should().BeFalse();
emittedError.Should().BeNull();
}

[Fact]
public void EmitFetchFailures_EmitsOneSummaryForTheConfigurationFile()
{
var collector = new TestDiagnosticsCollector(output);
var crossLinks = BuildCrossLinksWithFetchFailure(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P2 (Medium)

These tests use xUnit APIs ([Fact], the ITestOutputHelper primary-constructor parameter), but the test projects run on TUnit. They also call new TestDiagnosticsCollector(output), and Elastic.Markdown.Tests.TestDiagnosticsCollector only has a parameterless constructor. The file won't compile, so it breaks the whole Elastic.Markdown.Tests project build and the new regression coverage never runs. Switch to [Test] and new TestDiagnosticsCollector().

Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.

{
[repository] = DocSetRegistry.Internal
}.ToFrozenDictionary(),
FetchFailures = new Dictionary<string, string> { [repository] = failureReason }.ToFrozenDictionary()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P3 (Low)

Add regression coverage that obtains this result from DocSetConfigurationCrossLinkFetcher with a failing ILinkIndexReader. Both new tests populate FetchFailures manually, so they still pass if the production fetcher stops recording failures entirely. Cover a registry-wide exception and a repository-level failure alongside a successful repository, asserting the failure map, IsComplete, and diagnostic suppression from the actual fetched result.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

@reakaleek reakaleek closed this Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants