Skip to content

Add timezone validation #3679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 4, 2025
Merged

Add timezone validation #3679

merged 2 commits into from
Jul 4, 2025

Conversation

mazzz1y
Copy link
Contributor

@mazzz1y mazzz1y commented Jul 3, 2025

My machine accidentally has a symlink in /etc/timezone instead of a proper timezone file, and I spent some time investigating why cloud-init doesn't install anything in the guest, with this error:

[    5.994555] cloud-init[685]: 2025-07-03 09:19:09,880 - util.py[WARNING]: Failed loading yaml blob. unacceptable character #x0000: special characters are not allowed
[    5.996367] cloud-init[685]:   in "<unicode string>", position 88
[    5.997206] cloud-init[685]: 2025-07-03 09:19:09,880 - cloud_config.py[WARNING]: Failed at merging in cloud config part from part-001: empty cloud config

This PR adds timezone validation using the native Go way. In my case, it prints this warning and falls back to an empty value:

WARN[0000] invalid timezone "TZif2\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\b\x00\x00..." 

Signed-off-by: Dmitry Rubtsov <[email protected]>
Copy link
Member

@alexandear alexandear left a comment

Choose a reason for hiding this comment

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

Please add unit tests to cover your changes

@mazzz1y mazzz1y marked this pull request as draft July 3, 2025 11:51
@mazzz1y
Copy link
Contributor Author

mazzz1y commented Jul 3, 2025

I've added platform-specific build constraints as @AkihiroSuda suggested, refactored the function, and added tests for the time-zone extraction function.

@mazzz1y mazzz1y marked this pull request as ready for review July 3, 2025 19:04
@mazzz1y mazzz1y requested review from alexandear and AkihiroSuda July 3, 2025 19:06
@AkihiroSuda AkihiroSuda added this to the v1.2.0 milestone Jul 3, 2025
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda merged commit b94e2fc into lima-vm:master Jul 4, 2025
36 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