Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix wonky writing to sarif_file #4368

Merged
merged 2 commits into from
Oct 18, 2024
Merged

Fix wonky writing to sarif_file #4368

merged 2 commits into from
Oct 18, 2024

Conversation

Qalthos
Copy link
Contributor

@Qalthos Qalthos commented Oct 16, 2024

Fixes #4349

We're misusing Path.open() to look like we're using pathlib when we're effectively calling open(sarif_file) with more steps. The problem is that somewhere, sarif_file is getting picked up as AnsibleUnicode, which passes through Path.open when provided in place of the path object, but not in Python 3.10, where Path.open() is less straightforward in its implementation.

This fixes the issue, but does not solve the underlying problem, which is that Options.sarif_file is typed as a Path, but appears to take the value of a string. Either Options needs to be fixed to return this as a Path or the type should be fixed.

The change from open() -> write() to write_text() is not strictly related but looks a lot cleaner and forces the inconsistent usage to be an error.

@ssbarnea ssbarnea marked this pull request as ready for review October 18, 2024 10:31
@ssbarnea ssbarnea requested a review from a team as a code owner October 18, 2024 10:31
@ssbarnea ssbarnea merged commit 716f283 into ansible:main Oct 18, 2024
27 checks passed
@Qalthos Qalthos deleted the sarif_file branch October 23, 2024 12:34
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

ansible-lint fails with sarif_file parameter enabled
2 participants