Skip to content

file: validate output path for OS-specific invalid characters#4053

Open
twmb wants to merge 1 commit intomainfrom
1005
Open

file: validate output path for OS-specific invalid characters#4053
twmb wants to merge 1 commit intomainfrom
1005

Conversation

@twmb
Copy link
Contributor

@twmb twmb commented Mar 2, 2026

Override the benthos file output with a connect-local implementation that rejects characters causing silent data loss: colons on macOS (HFS+/APFS maps ':' to '/'), and <, >, :, ", |, ?, * plus control characters on Windows. NUL bytes are rejected on all platforms.

Fixes #1005.

@claude
Copy link

claude bot commented Mar 2, 2026

Claude finished @twmb's task in 4m 40s —— View job


  • Setup: fetch PR data and read agent guidelines
  • Step 1: Commit policy validation
  • Step 2: Code review
  • Step 3: Post summary

Commits

LGTM

Review

Clean implementation that overrides the benthos file output to add OS-specific path validation. Registration pattern, field name constants, config parsing, mutex usage, and test structure all follow project conventions. One minor pattern violation found.

  1. Error wrap prefix at output_file.go#L187 uses "path interpolation error: %w" instead of gerund form ("interpolating path: %w") per godev.md.

func (w *fileWriter) Write(_ context.Context, msg *service.Message) error {
path, err := w.path.TryString(msg)
if err != nil {
return fmt.Errorf("path interpolation error: %w", err)
Copy link

Choose a reason for hiding this comment

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

Error wrap prefix should use gerund form per godev.md: "Prefix with the action in gerund form". Change "path interpolation error: %w" to something like "interpolating path: %w".

Override the benthos file output with a connect-local implementation
that rejects characters causing silent data loss: colons on macOS
(HFS+/APFS maps ':' to '/'), and <, >, :, ", |, ?, * plus control
characters on Windows. NUL bytes are rejected on all platforms.

Fixes #1005.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@claude
Copy link

claude bot commented Mar 2, 2026

Claude finished @twmb's task in 1m 40s —— View job


  • Setup: fetch PR data and read agent guidelines
  • Step 1: Commit policy validation
  • Step 2: Code review
  • Step 3: Post summary

Commits

LGTM

Review

Reviewed 4 files: new file output override with OS-specific path validation (output_file.go, 336 lines), table-driven tests (output_file_test.go, 159 lines), doc reorder (file.adoc, +2/-2), and public wrapper import (package.go, +3 lines). Component registration, ConfigSpec construction, field name constants, ParsedConfig extraction, error handling, mutex encapsulation, idempotent Close, license headers (2026), and test patterns all follow project conventions.

  1. Error wrap prefix at output_file.go#L187 still uses "path interpolation error: %w" instead of gerund form ("interpolating path: %w") per godev.md. (Same issue as previous review.)

@mmatczuk
Copy link
Contributor

mmatczuk commented Mar 3, 2026

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.

Invalid output file name succeeds ambiguously

2 participants