Skip to content

fix(url): fail fast on missing sitemapFilter export (F-50, round-2 followup) - #37

Merged
markd3ng merged 1 commit into
mainfrom
r2/url-followup
Nov 28, 2026
Merged

markd3ng merged 1 commit into
mainfrom
r2/url-followup

Conversation

@markd3ng

@markd3ng markd3ng commented Nov 28, 2026 •

Copy link
Copy Markdown
Owner

Type of change

  • Bug fix (a non-breaking change that fixes an issue)

Related Issue

issue #10 — round-2 baseline quality audit, finding F-50.

Changes

Finding What changed Test
F-50 src/integration/resolve/load-config.ts gains requireConfigExport(), which asserts a loaded config module actually exports a named function and otherwise throws config/<file> must export <name>. src/integration/index.ts now resolves the sitemap predicate through it instead of sitemapModule.isSitemapPageAllowed as (page: string) => boolean, so a user config/sitemapFilter.ts override that omits the export fails at config-load with the config file named, rather than as a TypeError from inside @astrojs/sitemap at build time. tests/load-config.test.mjs: a real override that loads successfully but exports only isPageAllowed makes requireConfigExport throw the exact message; a config that does export isSitemapPageAllowed comes back unchanged and stays callable; a source-contract case pins index.ts to the validated call and forbids the bare assertion from returning.

How To Test

node --test tests/load-config.test.mjs   # 9 pass
node --test tests/*.test.mjs             # 663 pass, 0 fail
npm run type-check                       # clean (documented isolatedDeclarations exception only)
node_modules/.bin/biome check src/integration/resolve/load-config.ts src/integration/index.ts tests/load-config.test.mjs

Additional Notes

The contract for this campaign forbids running a full Astro build, so the fail-fast path is covered by the unit tests above (which exercise the real loadConfigModule + requireConfigExport pair on a temp fixture) plus the source-contract case, rather than by a build run.

  • I have formatted my code using Biome.
  • I have performed a self-review of my own code.
  • My changes generate no new warnings.

Summary by CodeRabbit

  • Bug Fixes
    • Sitemap filter configuration is now checked before use. If the required filter is missing or isn’t a function, the error identifies the relevant configuration file, making setup issues clearer to diagnose. This prevents invalid filter configurations from being accepted silently and improves feedback when customizing which pages appear in the sitemap.

…emapPageAllowed

- loadConfigModule only guarantees the file loaded; the bare `as (page: string) => boolean` cast then let a user override that forgets the predicate blow up inside @astrojs/sitemap's filter at build time, with a stack that points away from config/sitemapFilter.ts.
- requireConfigExport() checks the export is a function at load time and throws "config/sitemapFilter.ts must export isSitemapPageAllowed" instead.
@coderabbitai

coderabbitai Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The integration now validates the sitemap filter export with requireConfigExport. The helper returns function exports and throws an error naming the config file and required export when the value is not a function. Tests cover missing and valid exports.

Changes: Sitemap filter export validation

Layer / File(s) Summary
Add required config export check
src/integration/resolve/load-config.ts, tests/load-config.test.mjs
Adds requireConfigExport to return a named export when it is a function. Otherwise, it throws an error identifying the config file and required export. Tests cover a missing sitemap predicate.
Validate the sitemap filter during integration
src/integration/index.ts, tests/load-config.test.mjs
The integration obtains the sitemap predicate through requireConfigExport. Tests check successful predicate retrieval and confirm that the integration uses the helper instead of a bare type assertion.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • markd3ng/Suntory#1 — The PR is described as a follow-up fix within the audit remediation register covered by this issue.

Suggested reviewers: ycenzh, matsuzaka-yuki

Merge Risk: Minimal · up to f96f6

A sitemap filter override that omits the required export now fails early with a clear error that names the file and export. No merge-blocking risk was identified in the change.

Security architecture risk: Minimal · up to f96f6

Valid sitemap filters keep working as before. Missing or non-function filters now stop setup with a clear error instead of failing later when sitemap generation calls them. The change does not expand who can supply or run a filter.

Retained concerns
No architecture-level concerns identified.

Security review details

Trust Boundaries and Controls

  • observed — The loader still prefers the project override to the bundled config and imports the selected module before checking the export. The check validates the value handed to the sitemap integration; it does not sandbox the override or restrict what it can do during import.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a fail-fast check for a missing sitemapFilter export in the URL integration. It matches the summary, which adds requireConfigExport and uses it in src/integration/inde…
Description check Passed The description follows the repository template. It marks the Bug fix type, links issue #10 with finding F-50, and gives a Changes table and How To Test commands. It also states that a full Astro buil…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a fail-fast check for a missing sitemapFilter export in the URL integration. It matches the summary, which adds requireConfigExport and uses it in src/integration/index.ts. The ticket reference and 'round-2 followup' wording add noise but do not make the title wrong.

Full details: Description check

Explanation

The description follows the repository template. It marks the Bug fix type, links issue #10 with finding F-50, and gives a Changes table and How To Test commands. It also states that a full Astro build was not run. Three gaps remain. The Type of change section marks only the Bug fix item, which is fine. The Checklist section is omitted, so the CONTRIBUTING read, the 'pnpm format' step, and the 'npx astro check' result are not confirmed. The Screenshots section is not addressed, which is acceptable for a non-UI change. The description also reports 'npm run type-check' rather than the template's 'npx astro check'.

Resolution

Optional: add the template Checklist items, including whether 'npx astro check' passes with 0 errors, and mark or note that Screenshots do not apply. Confirm the Checklist items match the work performed.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6bd468ed-d87d-4191-8852-c2093adfdfdb
Commits

Reviewing files that changed from the base of the PR and between 269ecb4 and f96f610.

Files selected for processing: 3

  • src/integration/index.ts
  • src/integration/resolve/load-config.ts
  • tests/load-config.test.mjs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@markd3ng
markd3ng merged commit c33c2ab into main Nov 28, 2026
17 checks passed
markd3ng pushed a commit that referenced this pull request Nov 29, 2026
…onciliation

- closure-record: #38 diff verification, PR #30/#37/#38 walkthrough-only evidence + process exception,
  8 deferred findings mapped to existing issues #3/#4/#6/#7 (F-104 register-only), TD-1 serial口径, 56/19 stats reconciliation, #15 tracker, Project #3 alignment.
- engineering-tech-debt: TD-1..TD-6 ledger (tests/content race, F-20/F-88/F-90 src residuals, styl/README, favicon, F-104, shirone PRs).
- final report: errata for review exception, #30 src-partial DEFERRED, shirone#201 F-10, 23→19 skip口径, ledger path.
@markd3ng

markd3ng commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner Author

【收口审查记录 | Round 2 阶段收口(2026-11-29 Owner 批准)】

  • 本 PR 的 CodeRabbit 审查仅有 walkthrough 自动摘要(comment id RBCD_5083e108951d2c5e2441529d4a37f896),行内审查线程 0、无正式 review 结论事件——经 GraphQL reviewThreads/requests/reviews 核验。
  • 合并依据:c33c2abd 上 CI checks 全绿(Build Node 26.2.0 / Code quality / Comment regression fixtures 等)+ Owner diff 复核。按收口决议登记为流程例外,不伪造终局审查记录、不追加补审。
  • 证据登记:audit-and-analysis @ 6a8cf2e docs/evidence/2026-11-29-round2-bugfix/closure-record.md §2(含采集方法)。

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.

1 participant