Skip to content

Validate syslog_path when the configuration loads - #50

Merged
thomas-samoht merged 1 commit into
mainfrom
fix/validate-syslog-path
Nov 10, 2026
Merged

thomas-samoht merged 1 commit into
mainfrom
fix/validate-syslog-path

Conversation

@thomas-samoht

Copy link
Copy Markdown
Contributor

ConfigLogging now rejects a syslog_path that isn't host:port with a port from 1 to 65535, and the error names the bad value. Before this, a path without a port failed later at configure() with not enough values to unpack, and a port that wasn't a number failed with an int() error. Bracketed IPv6 hosts such as [fd00::1]:5514 now work.

@thomas-samoht
thomas-samoht marked this pull request as ready for review November 5, 2026 09:05
@thomas-samoht
thomas-samoht requested a review from a team as a code owner November 5, 2026 09:05
ricklambrechts
ricklambrechts previously approved these changes Nov 9, 2026
@thomas-samoht
thomas-samoht force-pushed the fix/validate-syslog-path branch from 96fb88e to 8130ed7 Compare November 9, 2026 15:57
@thomas-samoht
thomas-samoht changed the base branch from main to fix/stream-names-as-literals November 9, 2026 15:57
@thomas-samoht
thomas-samoht added this pull request to stack #61 November 9, 2026 15:57
ricklambrechts
ricklambrechts previously approved these changes Nov 9, 2026
@thomas-samoht
thomas-samoht dismissed ricklambrechts’s stale review November 10, 2026 08:51

The merge-base changed after approval.

@thomas-samoht
thomas-samoht force-pushed the fix/validate-syslog-path branch 3 times, most recently from 69084f1 to f65d1ce Compare November 10, 2026 09:11
ricklambrechts
ricklambrechts previously approved these changes Nov 10, 2026
@thomas-samoht
thomas-samoht dismissed ricklambrechts’s stale review November 10, 2026 09:12

The merge-base changed after approval.

@thomas-samoht
thomas-samoht force-pushed the fix/validate-syslog-path branch from f65d1ce to f7edf72 Compare November 10, 2026 09:13
Base automatically changed from fix/stream-names-as-literals to main November 10, 2026 09:13
Problem: ConfigLogging accepted any string as syslog_path. The builder
split it with rsplit(":", 1) and int(), outside the try block that turns
handler failures into an error naming syslog_path. A path without a port
failed at configure() with "not enough values to unpack (expected 2, got
1)", and a port that is not a number with an int() error, neither saying
which setting was wrong. A bracketed IPv6 host kept its brackets and could
not be resolved.

Fix: syslog_address() in config.py parses host:port once, strips the
brackets off an IPv6 host and requires a port from 1 to 65535. A field
validator on ConfigLogging runs it, so a bad value fails where the
configuration is loaded with an error naming syslog_path and the value.
The builder uses the same function for the handler address. An empty
syslog_path still means console only, as INI files tend to give one.
@thomas-samoht
thomas-samoht force-pushed the fix/validate-syslog-path branch from f7edf72 to 4469e51 Compare November 10, 2026 09:14
@thomas-samoht
thomas-samoht merged commit 362b75d into main Nov 10, 2026
3 checks passed
@thomas-samoht
thomas-samoht deleted the fix/validate-syslog-path branch November 10, 2026 09:14
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.

2 participants