Skip to content

[quality] remarkRewriteLinks isAsset assetBaseUrl short-circuit unit-covered but not end-to-end exercised #451

Backlog

Description

@hivecommons-hive

Finding

rewriteHref()'s isAsset = !!options.assetBaseUrl && assetExts.includes(ext) has a short-circuit branch for assetBaseUrl being falsy. That branch is 100% unit-covered (lib/remarkRewriteLinks/index.test.mts: 'leaves .csv links untouched when no assetBaseUrl is provided'; npm run test:coverage reports 100/100/100/100 repo-wide at commit 7dc5dd4) but no e2e build exercises it.

Verified with npx c8 --all --include lib/remarkRewriteLinks/index.ts node --test e2e/linkRewrite.test.mjs at commit 7dc5dd4: 99.32% stmt/line, 83.78% branch, with line 93 (the assetBaseUrl-falsy branch) uncovered.

This is distinct from the gaps #444/#445/#449 (open PRs) and #440/#441 (merged) already address - none of those touch this branch.

Unlike those gaps, this branch looks structurally unreachable through the real build: docusaurus.config.ts always wires the plugin with assetBaseUrl from getBuildContext(repo), whose assetBaseUrl field (${assetRepo}/blob/${assetBranch}) is always a non-empty string by construction. There is no BUILD_ENV/env-var combination that makes getBuildContext omit it, so an e2e test can only reach this branch by constructing a Docusaurus build that wires remarkRewriteLinks without assetBaseUrl - different from the real production wiring, not a path a genuine e2e assertion should fabricate.

Recommendation

No test-code fix is proposed here: an e2e test that rewires the plugin outside docusaurus.config.ts's real configuration would test a configuration the site never uses, not close a genuine end-to-end gap. Two options for a maintainer to pick between, and this is advisory rather than actionable from this lane since it crosses into design judgement about dead-code/branch simplification:

  1. Leave as-is - the branch exists for direct API consumers of rewriteHref/remarkRewriteLinks outside this repo's own Docusaurus config (it is an exported, documented option), so unit coverage is the right bar for it, and this issue can close as 'won't test further'.
  2. If the branch is considered genuinely dead in this repo's own build, note that in the file's JSDoc so a future reader doesn't go looking for an e2e test that cannot meaningfully exist.

Priority

  • Evidence: unit-covered (lib/remarkRewriteLinks/index.test.mts), not end-to-end-covered (no e2e fixture reaches it, and by design cannot without faking the config wiring)
  • Priority: 2 (medium) - unit-covered, not end-to-end-covered
  • Impact: low (narrow branch, exported for external API consumers, not reachable from this site's own build)
  • Effort: low to decide, none to implement (no e2e test proposed)

Filed by quality agent (hold-gated mode)


🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-boq9 | SHA: 7dc5dd4

Activity

  1. added
    testing
    agent/quality
    on Nov 24, 2026
  2. hivecommons-hive commented on Nov 24, 2026

    @hivecommons-hive
    ContributorAuthor

    Folded finding. This was filed as a separate issue, but 1 open agent-filed issue (plus 4 closed as completed in the last 14 days) already cite e2e/linkRewrite.test.mjs, so it was folded into the oldest of them instead of opening another. Treat this issue as the tracker for that component: prefer one structural fix that covers every folded variant over a PR per variant.

    [quality] getBuildContext BUILD_ENV default-fallback (real production path) unit-covered but not end-to-end exercised

    Finding

    getBuildContext.ts line 14:

    const buildEnv = process.env.BUILD_ENV || 'production';

    The || 'production' default is the real Netlify production code path:
    netlify.toml's [context.production] runs npm run build:production
    (npm run _build -> docusaurus build), and neither that script nor
    build:preview sets BUILD_ENV. Only the local npm run build script sets
    BUILD_ENV=dev explicitly. So in a genuine production deploy, BUILD_ENV
    is unset and this fallback is what decides isProd/assetBaseUrl for the
    whole site.

    This default is 100% unit-covered in isolation
    (lib/getBuildContext.test.mts: "defaults to production when BUILD_ENV is
    unset"), but no e2e build exercises it. e2e/linkRewrite.test.mjs's
    "production build wires isProd-dependent editUrl/url end-to-end" suite
    explicitly sets BUILD_ENV: 'production' in the child process env (line
    167) rather than leaving it unset, so the real build only ever takes the
    explicit-string branch of line 14, never the || default branch. A
    regression that broke the default (e.g. swapping the fallback to
    'development') would pass every existing unit and e2e test while
    breaking the real production build.

    Verified with combined coverage: npx c8 --all --include 'lib/**/*.ts' --reporter=json node --test 'e2e/**/*.test.mjs' at commit 3c1e2b5 reports
    lib/getBuildContext.ts branch 3 (line 14, the || default) at 0 hits,
    even though npm run test:coverage (unit) reports the same file at
    100/100/100/100. Confirmed locally that a build with BUILD_ENV deleted
    from the child env (rather than set to 'production') produces identical
    output (same og:url/editUrl) to the existing explicit-production e2e
    build, proving the default is reachable and assertable without fabricating
    any wiring the real build doesn't use.

    Recommendation

    Add an e2e case that builds with BUILD_ENV deleted (not set to any
    value) and asserts the same production assertions as the existing
    explicit-BUILD_ENV=production suite, so a regression in the default
    itself fails even when the explicit-string path still passes.

    Priority

    • Evidence: unit-covered (lib/getBuildContext.test.mts), not
      end-to-end-covered (no e2e build leaves BUILD_ENV unset; see
      e2e/linkRewrite.test.mjs line 167)
    • Priority: 2 (medium) - unit-covered, not end-to-end-covered
    • Impact: medium (this is the actual code path the real Netlify production
      deploy takes, not a byway)
    • Effort: low (one new e2e describe block)

    Filed by quality agent (hold-gated mode)


    🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-boq9 | SHA: unknown


    Folded finding. This was filed as a separate issue, but 1 open agent-filed issue (plus 4 closed as completed in the last 14 days) already cite e2e/linkRewrite.test.mjs, so it was folded into the oldest of them instead of opening another. Treat this issue as the tracker for that component: prefer one structural fix that covers every folded variant over a PR per variant.

    [quality] getGitHubRepoUrl.ts SSH-style REPOSITORY_URL branch unit-covered but not end-to-end exercised

    Finding

    getGitHubRepoUrl.ts's normalizeGitHubUrl() has a regex branch for SSH-style remote URLs (git@github.com:owner/repo(.git)?). That branch is 100% unit-covered (lib/getGitHubRepoUrl.test.mts: 'normalizes an SSH REPOSITORY_URL') but no e2e build exercised it: e2e/linkRewrite.test.mjs's deploy-preview suite only ever sets REPOSITORY_URL to an HTTPS-style value.

    Verified with npx c8 --all --include lib/getGitHubRepoUrl.ts node --test e2e/linkRewrite.test.mjs: line 5 (the SSH-match branch) was uncovered end-to-end before this fix.

    Unlike the git-remote/branch fallback gaps in #444/#445/#449 (which depend on the real checkout's actual git state and can't be faked without testing a configuration the site never uses), this branch is genuinely testable end-to-end: REPOSITORY_URL is an overridable env var the production code reads directly via process.env.REPOSITORY_URL, so a deploy-preview build can set it to an SSH-style string and exercise the exact same normalization path a real Netlify build would take if it ever populated REPOSITORY_URL with an SSH remote.

    Recommendation

    Add an e2e fixture (deploy-preview build with REPOSITORY_URL: 'git@github.com:example-org/example-repo.git') asserting the rewritten .csv asset link uses the normalized HTTPS form. See the companion PR.

    Priority

    • Evidence: unit-covered (lib/getGitHubRepoUrl.test.mts), not end-to-end-covered (no e2e fixture reached the SSH branch) before this PR
    • Priority: 2 (medium) - unit-covered, not end-to-end-covered
    • Impact: low (narrow branch, but a regression there would silently break SSH-sourced REPOSITORY_URL values with no CI signal)
    • Effort: low (one new e2e describe block, no production code change)

    Filed by quality agent (hold-gated mode)


    🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-boq9 | SHA: 3c1e2b5


    Folded finding. This was filed as a separate issue, but 1 open agent-filed issue (plus 4 closed as completed in the last 14 days) already cite e2e/linkRewrite.test.mjs, so it was folded into the oldest of them instead of opening another. Treat this issue as the tracker for that component: prefer one structural fix that covers every folded variant over a PR per variant.

    [quality] getGitHubRepoUrl.ts non-GitHub REPOSITORY_URL fallback unit-covered but not end-to-end exercised

    Finding

    normalizeGitHubUrl's final return undefined (lib/getGitHubRepoUrl.ts line 12, reached when a REPOSITORY_URL is present but matches neither the SSH (git@github.com:owner/repo) nor HTTPS (https://github.com/owner/repo) regex) was 100% unit-covered in isolation (lib/getGitHubRepoUrl.test.mts: 'falls back to the git remote when REPOSITORY_URL does not parse') but no e2e build exercised it.

    Verified with npx c8 --all --include lib/getGitHubRepoUrl.ts node --test e2e/linkRewrite.test.mjs at commit 3c1e2b5: 93.93% stmt/line, 57.14% branch, with lines 11 and 19 uncovered.

    This is distinct from the gaps #444/#454/#455 (open PRs) address: those cover the SSH-match branch and the git-branch/remote real-fallback path, none of which reach normalizeGitHubUrl's final fallback for a REPOSITORY_URL that parses as neither GitHub form (e.g. a non-GitHub host such as a GitLab mirror, or a malformed URL).

    Like #455's reasoning for the SSH branch, this is reachable without faking any config: REPOSITORY_URL is an overridable input the production code reads directly, so pointing it at a non-GitHub host during a real deploy-preview build exercises the exact same code path Netlify would take if it (or a mirror setup) ever populated REPOSITORY_URL with something that isn't github.com-shaped.

    Recommendation

    Add an e2e test (in e2e/linkRewrite.test.mjs, alongside the existing deploy-preview suites) that runs a real docusaurus build with REPOSITORY_URL set to a non-GitHub URL (e.g. https://gitlab.com/example-org/example-repo) and GIT_DIR/GIT_WORK_TREE pointed at a nonexistent path (so the git-remote fallback can't mask the malformed REPOSITORY_URL with this checkout's real github.com origin), then assert the rewritten .csv asset link falls all the way back to the hard-coded repo/main.

    Priority

    • Evidence: unit-covered (lib/getGitHubRepoUrl.test.mts), not end-to-end-covered before this issue (no e2e fixture reached it)
    • Priority: 2 (medium) - unit-covered, not end-to-end-covered
    • Impact: low (narrow fallback branch, defensive against unexpected REPOSITORY_URL shapes)
    • Effort: low (one new e2e describe block, following the existing deploy-preview pattern)

    Filed by quality agent (hold-gated mode)


    🐝 Hive Agent: quality | Instance: hosted-available-lke648397-260827-boq9 | SHA: 3c1e2b5

  3. hivecommons-hive commented on Nov 24, 2026

    @hivecommons-hive
    ContributorAuthor

    Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

    PR #454 covers this issue: #454

    The PR body says this is partial/non-closing work (Refs/Part of or leave-open wording), so Hive will not add a closing keyword. GitHub will not show its issue-list PR icon without a closing keyword; the stage comment is the link.

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

    agent/qualitytesting

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions