Skip to content

[Feature Request]: Validate redirects.yml inputs #1538

Closed

Description

@reakaleek

Prerequisites

  • I have searched existing issues to ensure this feature hasn't already been requested
  • I have tested using the latest version of docs-builder

What problem are you trying to solve?

When you redirect to a path without .md extension, you get unexpected results in during cross-link validation.

The configuration in apm-agent-android causes this error during an assembler build.

error::d.a.b.AssemblerBuilder:: An error occurred while resolving cross-link opentelemetry://reference/edot-sdks/android: 'reference/edot-sdks/android' is not a valid link in the 'opentelemetry' cross link index: https://elastic-docs-link-index.s3.us-east-2.amazonaws.com/elastic/opentelemetry/main/links.json
error::d.a.b.AssemblerBuilder:: An error occurred while resolving cross-link opentelemetry://reference/edot-sdks/android/getting-started: 'reference/edot-sdks/android/getting-started' is not a valid link in the 'opentelemetry' cross link index: https://elastic-docs-link-index.s3.us-east-2.amazonaws.com/elastic/opentelemetry/main/links.json
error::d.a.b.AssemblerBuilder:: An error occurred while resolving cross-link opentelemetry://reference/edot-sdks/android/troubleshooting: 'reference/edot-sdks/android/troubleshooting' is not a valid link in the 'opentelemetry' cross link index: https://elastic-docs-link-index.s3.us-east-2.amazonaws.com/elastic/opentelemetry/main/links.json

Proposed Solution

Validate the redirects.yml file and it's values.

Examples and Research

No response

Alternative Solutions

No response

Additional Context

No response

How important is this feature to you?

Nice to have

Activity

  1. reakaleek commented on Jul 8, 2025

    @reakaleek
    MemberAuthor

    This PR should fix the error.

  2. cotti commented on Jul 8, 2025

    @cotti
    Contributor

    Linting rules:

    • Paths should not be absolute (/reference/... -> reference/...)
    • Redirect rule keys (from) should not reference a different repository (other-repo://reference/... -> reference/...)
    • Redirect rules must be from file to file (path/to/doc -> path/to/doc.md)
  3. bmorelli25 commented on Jul 11, 2025

    @bmorelli25
    Member

    Is this done?

  4. KOTungseth commented on May 14, 2026

    @KOTungseth
    Contributor

    @reakaleek did your PR close this issue?

  5. cotti commented on Jun 3, 2026

    @cotti
    Contributor

    AI triage

    Automated investigation against the current codebase. A human still needs to confirm before any code change.

    Original concern

    redirects.yml accepts malformed entries (e.g. targets without a .md extension, absolute or cross-repo-prefixed from keys) that parse fine locally but blow up later during assembler cross-link resolution — so the request is to validate the inputs of redirects.yml up front.

    Findings

    • RedirectFile.cs:L55-L124 — the parser reads each from key verbatim into the dictionary. It does not reject absolute paths (/reference/...), cross-repo prefixes (other-repo://...), or keys missing a .md extension, and there is no cycle / "source still exists" check. Unknown top-level keys only get a soft warning (L42-L44).
    • DocumentationSet.ValidateRedirectsExists():L140-L194 — validates only the to target: if it contains :// it must be a well-formed URI, otherwise it must resolve to an existing markdown file ("does not exist" / "is not a markdown file"). This is the one place a .md-less target is caught, but it runs per single-repo build and never inspects the from key.
    • LocalChangesService.ValidateRedirects():L23-L96 (exposed as the diff command, DiffCommands.cs:L30-L41) — checks completeness (every deleted/renamed page has a redirect) and has one narrow shape rule that flags a root-relative from key vs a docset-relative one (L75-L80). It does not enforce the general input rules requested here.
    • AssemblerBuilder.Resolve():L140-L157 (mirrored in CodexBuildService.CollectRedirects) — at assemble time, keys/values that are well-formed absolute URIs are treated as cross-repo links and everything else as relative. This is exactly where the opentelemetry://reference/edot-sdks/android error in the report surfaces: a malformed entry becomes a cross-link that fails to resolve, with no upfront redirects.yml validation to catch it earlier.

    Verdict

    Partially done

    Target validation exists — to must point to an existing markdown file (or be a valid URI), and a separate diff check enforces that deleted/renamed pages have redirects. But none of the three input-linting rules called out in the thread are implemented: absolute from paths, cross-repo-prefixed from keys, and the file→file (.md) requirement on keys are all accepted silently at parse time, and there is no cycle / source-still-exists check. So the core ask (validate the inputs) is unmet.

    Proposal

    The mechanical home for this is parse-time validation in RedirectFile.ReadRedirects (emit errors via the existing YamlStreamReader), since that is where every from/to is already in hand and the diff, single-repo, and assembler paths all flow through it. Concretely, per entry: reject keys starting with / (absolute), reject keys containing :// (cross-repo), and require .md/.mdx on from keys; optionally detect trivial cycles (a.md -> a.md). Open questions for a human before coding:

    • Writer-facing (ai:writer-question): should violations be hard errors or warnings? Hard errors will break any repo whose redirects.yml currently contains a now-illegal entry (e.g. the apm-agent-android case) until it is fixed — is that acceptable, or does this need a deprecation/warning window + migration note? What exact wording should the error use so writers can self-correct?
    • Engineering (ai:eng-question): is RedirectFile the right layer (vs. a dedicated validator invoked by the diff CI command), and should the same rule set run in both single-repo and assembler builds so the failure shows up at authoring time instead of at assemble time?

    Related issues

    Part of the Link checks & Redirects cluster — meta #949 (open). Adjacent open redirect-validation gaps: #1920 (xref evades the deleted-page check), #736 (error-checking for removed files/URLs), #1181 (handling of absolute URL path references — overlaps the "no absolute paths" rule). Prior decisions in this area: #759, #1892, #1779 (all closed). No exact duplicate — #1538 is the only open issue scoped to validating redirects.yml inputs.

    Notes

    • The linked apm-agent-android#554 fixed that repo's redirects.yml, but it is a content fix in another repo — it does not add any validation to docs-builder, so this issue remains open on its merits.
    • No docs-builder PR/commit has implemented the requested input linting; the only redirect-validation work since this issue was filed (2025-07-08) is around completeness/path-normalization for the diff check (e.g. commits fc84db91, 223d560c, 2026-05-13) and excluded paths (#3095).
    • The maintainer's own comment already specifies the three lint rules — that is a good seed for the implementation once the error-vs-warning rollout question is answered.
  6. added
    ai-triaged
    ai:eng-question
    ai:writer-question
    on Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai-triagedai:eng-questionai:writer-questionenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions