Skip to content

Conversation

@dbungert
Copy link
Member

Expand the run() wrapper to handle logging and unicode decode failures in general.

The original problem reports udev decode failures involving a NTFS partition with a label similar to 'NTFS réservée'. I am unable to construct that with NTFS, but a ext4 version was instructional. The subsequent dumpe2fs has invalid output.

Pyudev seems to handle this all well, I was unable to coax decode failures from it.

I think the robustness check is interesting for now, and if we get more info on reproduction steps, further work can be considered.

LP: #2011344

Expand the run() wrapper to handle logging and unicode decode failures
in general.

LP: #2011344
@dbungert dbungert requested a review from ogayot March 28, 2023 23:40
@ogayot
Copy link
Member

ogayot commented Mar 29, 2023

I'm a bit confused, does this change solve a problem or does it give more information to investigate?

I wonder if we should not define a error handler to log the error and then call codecs.backslashreplace_errors or something. Thoughts?

excerpt

import codecs

def f(exc):
    print("oops", exc)
    return codecs.backslashreplace_errors(exc)


codecs.register_error('probert-run-unicode', f)

data = b'r\xe9serv\xe9e'

print(data.decode(errors='probert-run-unicode'))

(we can pass the handler to subprocess directly)

@dbungert
Copy link
Member Author

I'm a bit confused, does this change solve a problem or does it give more information to investigate?

dumpe2fs is passing the latin1 string, which causes problems when we try to act on the non-label output. I'll incorporate your suggestion, which I think salvages the sizing information we are intrested in.

@dbungert
Copy link
Member Author

I'm a bit confused, does this change solve a problem or does it give more information to investigate?

The goal is a bit of both.
So in the ext4 example, we no longer acquire the sizing information, because the output is garbled due to not being in the expected utf8 format. So we effectively skip offering that as a resizable partition.

Also, the goal is to log the reasons why the resize tool didn't succeed, so it shows that as well.

for line in stream.splitlines():
for line in log_input.splitlines():
log.debug(line)
return text
Copy link
Member

Choose a reason for hiding this comment

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

if we still return None here in case of UnicodeDecodeError, we don't solve the issue with the sizing information, do we?

@dbungert dbungert marked this pull request as draft April 10, 2023 21:26
@ogayot ogayot changed the base branch from master to main May 16, 2025 08:25
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