Skip to content
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

Soften error to warning in template processor when fails to read file #1924

Merged
merged 5 commits into from
Dec 9, 2024

Conversation

sfc-gh-pjafari
Copy link
Contributor

@sfc-gh-pjafari sfc-gh-pjafari commented Dec 5, 2024

Pre-review checklist

  • I've confirmed that instructions included in README.md are still correct after my changes in the codebase.
  • I've added or updated automated unit tests to verify correctness of my new code.
  • I've added or updated integration tests to verify correctness of my new code.
  • I've confirmed that my changes are working by executing CLI's commands manually on MacOS.
  • I've confirmed that my changes are working by executing CLI's commands manually on Windows.
  • I've confirmed that my changes are up-to-date with the target branch.
  • I've described my changes in the release notes.
  • I've described my changes in the section below.

Changes description

Template processor should not fail if it can't read a file.

@sfc-gh-pjafari sfc-gh-pjafari requested a review from a team as a code owner December 5, 2024 18:14

if expanded_template != file.contents:
file.edited_contents = expanded_template
except UnicodeDecodeError as err:
Copy link
Contributor

Choose a reason for hiding this comment

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

why would we get this error?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it makes sense for binary files.

Copy link
Collaborator

Choose a reason for hiding this comment

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

So that's where those errors are coming from 🤯

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sfc-gh-mchok you saw these on the dashboard?! Yeah our template processor was dying every time there was a file it couldn't read :D


if expanded_template != file.contents:
file.edited_contents = expanded_template
except UnicodeDecodeError as err:
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it makes sense for binary files.

Copy link
Contributor

@sfc-gh-bdufour sfc-gh-bdufour left a comment

Choose a reason for hiding this comment

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

No test?

@sfc-gh-pjafari sfc-gh-pjafari enabled auto-merge (squash) December 5, 2024 21:17
bundle_result = bundle_files(tmp_dir, file_name, file_contents)
templates_processor = TemplatesProcessor(bundle_ctx=bundle_result.bundle_ctx)
with mock.patch(
f"{ARTIFACT_PROCESSOR}.ProjectFileContextManager.__enter__",
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just mock edit_file? That's the public contract, whereas this is an implementation detail.

@sfc-gh-pjafari sfc-gh-pjafari merged commit a6368d4 into main Dec 9, 2024
20 checks passed
@sfc-gh-pjafari sfc-gh-pjafari deleted the pj-template-processor-error branch December 9, 2024 14:45
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.

4 participants