Skip to content

fix(log): filenotfound exception when cfn submit cluttering logs #213

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
Nov 4, 2022

Conversation

mmaeng
Copy link
Contributor

@mmaeng mmaeng commented Nov 4, 2022

Closes #212

switch try/except to if path exists before build path removal

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Contributor

@kddejong kddejong 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 confused how this fixes the FileNotFoundError in the logs. Aren't we catching that exception and not printing it?

@mmaeng
Copy link
Contributor Author

mmaeng commented Nov 4, 2022

We are catching it but it is still showing up in the logs. So switched to a existence check first.

[2022-10-21T01:48:21Z] DEBUG    - Package started
[2022-10-21T01:48:21Z] DEBUG    - '/home/mmaeng/source/test-mod/build' not found, skipping removal
Traceback (most recent call last):
  File "/home/mmaeng/source/cloudformation-cli/.venv/lib/python3.8/site-packages/rpdk/typescript/codegen.py", line 226, in _remove_build_artifacts
    shutil.rmtree(deps_path)
  File "/usr/lib/python3.8/shutil.py", line 709, in rmtree
    onerror(os.lstat, path, sys.exc_info())
  File "/usr/lib/python3.8/shutil.py", line 707, in rmtree
    orig_st = os.lstat(path)
FileNotFoundError: [Errno 2] No such file or directory: '/home/mmaeng/source/test-mod/build'

@kddejong
Copy link
Contributor

kddejong commented Nov 4, 2022

In other parts of the code we use shutil.rmtree(docs_path, ignore_errors=True) would that also fix it?

@mmaeng
Copy link
Contributor Author

mmaeng commented Nov 4, 2022

Switched to rmtree with ignore. That also looks to fix the error.

@mmaeng mmaeng merged commit 6749ca1 into aws-cloudformation:master Nov 4, 2022
@mmaeng mmaeng deleted the fix/issue212 branch November 4, 2022 20:40
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.

clean up filenotfound error in logs during cfn submit
3 participants