Skip to content

Improve error messages#1440

Merged
Luap99 merged 1 commit intocontainers:mainfrom
ashley-cui:create
Apr 24, 2026
Merged

Improve error messages#1440
Luap99 merged 1 commit intocontainers:mainfrom
ashley-cui:create

Conversation

@ashley-cui
Copy link
Copy Markdown
Member

Add more detail to errors for network create validation

@packit-as-a-service
Copy link
Copy Markdown

Ephemeral COPR build failed. @containers/packit-build please check.

@ashley-cui ashley-cui marked this pull request as draft April 23, 2026 20:02
@ashley-cui ashley-cui marked this pull request as ready for review April 24, 2026 00:33
@ashley-cui
Copy link
Copy Markdown
Member Author

ashley-cui commented Apr 24, 2026

Good to go, should fix the last failing test in containers/podman#28570

@containers/netavark-maintainers PTAL

Copy link
Copy Markdown

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

(I’m not a maintainer here, so I can’t approve / reject.)

Consider {:?}: if the value is already known to be not using the correct syntax, could it contain newlines, full sentences, or other surprising data?

@Luap99
Copy link
Copy Markdown
Member

Luap99 commented Apr 24, 2026

Consider {:?}: if the value is already known to be not using the correct syntax, could it contain newlines, full sentences, or other surprising data?

Well that is one of the nicer things about rust, String musts be valid utf8, so at least some dangerous bytes are skipped that way. Sure newlines and such can still happen so quoting them here does make sense I guess. I don't think we have paid much attention to any of this so far here.

My personal going so far is anything netavark receives is consider trusted input from a security POV. If something gives us garbage I am fine producing garbage.

Copy link
Copy Markdown
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM, minus the valid test

Comment thread test/700-create.bats Outdated
@test "create - fail with invalid network name" {
expected_rc=1 run_netavark create < ${TESTSDIR}/testfiles/create/invalid-name.json
assert_json ".error" "Invalid characters in network name: must match [a-zA-Z0-9][a-zA-Z0-9_.-]" "Error message contains 'Invalid characters in network name'"
assert_json ".error" "Invalid characters in network name badname!: must match [a-zA-Z0-9][a-zA-Z0-9_.-]*" "Error message contains 'Invalid characters in network name'"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

test need quotes around the name now

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed, tyvm!

Add more detail to errors for network create validation

Signed-off-by: Ashley Cui <acui@redhat.com>
@Luap99 Luap99 enabled auto-merge April 24, 2026 15:39
@Luap99 Luap99 merged commit 0043f76 into containers:main Apr 24, 2026
27 checks passed
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.

3 participants