Skip to content

Harden changelog CI path: scope roots, SecurityException, native gate errors - #3745

Merged
cotti merged 1 commit into
mainfrom
worktree-fix-pr-body-scoped-fs
Jul 30, 2026
Merged

Harden changelog CI path: scope roots, SecurityException, native gate errors#3745
cotti merged 1 commit into
mainfrom
worktree-fix-pr-body-scoped-fs

Conversation

@cotti

@cotti cotti commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up hardening on top of #3742 (RealReadForRunnerTemp / ChangelogPrBodyReader), plus the gate-logic change requested by @[colleague] to make evaluate-pr natively signal failure for no-label / no-title results.

  • FileSystemFactory.ScopeCurrentWorkingDirectory: filter ancestor extension roots in addition to descendants. An ancestor would subsume the working root and produce overlapping scope roots, causing ScopedFileSystem to throw ArgumentException — the same class of crash fixed in a96ef86 / 3c5f970 for Codex nested paths.
  • FileSystemFactory.RealReadForRunnerTemp: fix docstring that incorrectly claimed the fallback triggers when "not in CI" (nothing consulted IsRunningOnCI).
  • ChangelogCommand: catch SecurityException alongside IOException when reading --prs / --issues from a file. ScopedFileSystemException extends SecurityException, so an out-of-scope path escaped as an unhandled exception.
  • ChangelogPrEvaluationService.EvaluatePr: emit collector.EmitError(...) + return false for NoTitle and NoLabel (type and product) results. ServiceInvoker already translates collector.Errors > 0 → exit code 1, so docs-builder now fails natively without a separate bash Gate step. GitHub Actions outputs (status, label-table, etc.) are still written before the process exits, so downstream steps with if: always() can still read them.

The companion docs-actions PR is elastic/docs-actions#257.

Tests

  • FileSystemFactoryTests: RealReadForRunnerTemp (unset → falls back to RealRead, sibling RUNNER_TEMP allows staged file read), ScopeCurrentWorkingDirectory ancestor root guard.
  • ChangelogPrBodyReaderTests: outside-scope emits Warning, missing file emits Warning.
  • ChangelogPrEvaluationServiceTests: TDD gate tests — NoTitle, NoTypeLabel, NoProductLabel each emit a Severity.Error diagnostic and return false; success emits no diagnostics. All existing no-label / no-title tests updated from BeTrue() to BeFalse().

Test plan

  • ./build.sh unit-test green
  • evaluate-pr on a PR with no changelog label → exit code 1, ::error:: annotation visible in Actions UI
  • evaluate-pr on a PR with a valid changelog label → exit code 0, ::notice::proceed

🤖 Generated with Claude Code

… errors

- FileSystemFactory.ScopeCurrentWorkingDirectory: filter ancestor extension
  roots (would produce overlapping scope roots and crash ScopedFileSystem,
  same class of bug fixed in a96ef86 for Codex nested paths)
- FileSystemFactory.RealReadForRunnerTemp: fix docstring that incorrectly
  claimed the fallback triggers when 'not in CI'

- ChangelogCommand: catch SecurityException alongside IOException when reading
  --prs / --issues from file (ScopedFileSystemException extends SecurityException)

- ChangelogPrEvaluationService.EvaluatePr: emit collector.EmitError + return
  false for NoTitle and NoLabel (type and product) results so docs-builder
  exits 1 natively, eliminating the need for a separate bash Gate step in CI.
  GitHub Actions outputs are still written before exit so downstream steps
  with if:always() can read status/label-table/etc.

Tests:
- FileSystemFactoryTests: RealReadForRunnerTemp (unset fallback, sibling temp
  dir), ScopeCurrentWorkingDirectory ancestor root guard
- ChangelogPrBodyReaderTests: outside-scope emits Warning, missing file emits
  Warning (assertions corrected from prior Error draft)
- ChangelogPrEvaluationServiceTests: gate TDD (NoTitle/NoLabel/NoProductLabel
  each emit error and return false, success emits no diagnostics); existing
  no-label/no-title tests updated from BeTrue to BeFalse

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cotti cotti added the fix label Jul 29, 2026
@cotti
cotti marked this pull request as ready for review July 29, 2026 18:30
@cotti
cotti requested a review from a team as a code owner July 29, 2026 18:30
@cotti
cotti requested a review from Mpdreamz July 29, 2026 18:30
@cotti
cotti merged commit b822fd7 into main Jul 30, 2026
24 of 25 checks passed
@cotti
cotti deleted the worktree-fix-pr-body-scoped-fs branch July 30, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants