fix(journal-log-writer): accept only absolute journal directory paths.#22771
Merged
vkalintiris merged 1 commit intoJun 18, 2026
Merged
Conversation
…rtup A relative journal_dir was accepted through Log::new init (the discarded canonicalize result left the path relative), then failed at first write with a cause-less "failed to create journal file in <path>" because repository::File::from_path only accepts absolute paths. To OTLP clients this surfaced as a permanent "Failed to write log entry" gRPC Internal error and dropped log batches. Validate that the journal directory is absolute as the first step of create_chain, before any I/O, returning an InvalidPath error that names the offending value, and enrich the residual create-file error to describe the real remaining failure mode (unparseable generated file path). Relative-path resolution stays the consumer's responsibility: netflow resolves its relative default against the netdata cache dir when one is available, and the new Log::new check is the safety net for the standalone case. Add tests and a directory-contract spec; note the requirement in the stock otel config.
stelfrag
approved these changes
Jun 18, 2026
Contributor
There was a problem hiding this comment.
No issues found across 6 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Config as OTEL Plugin Config
participant Env as Environment
participant Plugin as OTEL Plugin
participant Log as Log::new()
participant FS as Filesystem
participant Chain as OwnedChain
participant Repo as repository::File::from_path()
Note over Config,Repo: Journal Directory Validation Flow
Config->>Plugin: journal_dir (may be absolute from @logdir_POST@ or relative override)
Env->>Plugin: NETDATA_OTEL_LOGS_JOURNAL_DIR override (may be relative)
Plugin->>Log: new(journal_dir, config)
alt journal_dir is absolute
Log->>FS: canonicalize() to verify accessibility
FS-->>Log: canonical path
Note over Log: Proceed with journal creation
Log->>FS: load_machine_id()
FS-->>Log: machine ID
Log->>Chain: create_chain(path)
Chain->>FS: create directory if not exists
FS-->>Chain: directory created
Chain->>Repo: from_path() on generated file path
note over Chain,Repo: CHANGED: clearer error message on parse failure
alt file path parseable
Repo-->>Chain: valid File
Chain-->>Log: OwnedChain
Log-->>Plugin: Ok(Log)
else file path not parseable
Repo-->>Chain: error
Chain-->>Log: WriterError::FileCreation with detailed message
Log-->>Plugin: Error
end
else journal_dir is relative
Log-->>Plugin: CHANGED: WriterError::InvalidPath with offending value
Note over Log,Plugin: Fail-fast before any I/O - no directory created
end
Note over Config,Plugin: Consumer Responsibility
alt NetFlow Plugin path
Note over Config,Plugin: NetFlow resolves relative path vs NETDATA_CACHE_DIR before calling Log::new
end
vkalintiris
enabled auto-merge (squash)
June 18, 2026 16:24
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



SSIA.
Summary by cubic
Reject non-absolute journal directories at
Log::newinjournal-log-writerto fail fast with a clear error and avoid dropped logs on first write.Bug Fixes
journal_diris absolute before any I/O; returnWriterError::InvalidPathnaming the value.Migration
logs.journal_diris an absolute path (includingNETDATA_OTEL_LOGS_JOURNAL_DIRoverrides); relative values now fail at startup.Written for commit 48900ed. Summary will update on new commits.