Skip to content

Fix: render_terminal_png.py leaks raw traceback for missing input file - #476

Merged
yakew7 merged 1 commit into
yakew7:mainfrom
AchieverSana:fix/render-terminal-png-missing-input
Sep 7, 2026
Merged

Fix: render_terminal_png.py leaks raw traceback for missing input file#476
yakew7 merged 1 commit into
yakew7:mainfrom
AchieverSana:fix/render-terminal-png-missing-input

Conversation

@AchieverSana

Copy link
Copy Markdown
Contributor

Fixes render_terminal_png.py to handle missing input files cleanly instead of leaking a raw Python traceback.

Summary

Handles missing input files gracefully by printing error: <path> not found to stderr and exiting with code 2, matching the script's existing usage-error behavior.

Type

  • Audit
  • Explainer
  • Bug fix
  • Other

Audit checklist

  • I opened or linked a corresponding issue first
  • The folder is named after the domain, not the dataset
  • unfair.py includes protected attributes and prints the required output format
  • fair.py removes protected attributes and identified proxy variables
  • Both scripts use random_state=42 and an 80/20 train/test split
  • Proxy variables were actually tested, not just guessed
  • unfair.png and fair.png are included as PNG screenshots
  • The dataset is public and accessible without login or payment
  • The dataset file is included, or DATA.md is included if the file is too large
  • README.md includes the new results row and audit section
  • A notebook was added if the audit benefits from one

Before fairness gap:

After fairness gap:

Reduction:

Protected attribute(s):

Proxy variables dropped:


Explainer checklist

  • The file is in explainers/ and uses lowercase hyphenated naming
  • It includes a plain-language definition
  • It uses a real example from this repo or a documented real-world case
  • It includes runnable Python detection or measurement code
  • It acknowledges limitations or trade-offs
  • It links to related explainers or repo projects
  • It includes 2-3 primary sources
  • The Explainers table in README.md was updated

Linked issue

Closes #460

Wrap the input file read in a try/except FileNotFoundError and print
an 'error: <path> not found' message with exit code 2, matching the
existing usage-error style, instead of leaking a raw traceback.

Closes yakew7#460
@vercel

vercel Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

@AchieverSana is attempting to deploy a commit to the yashkewlani2020-gmailcom's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

Hey @AchieverSana, your first PR on Fair Code, that's awesome, thank you.

This project is about making AI more accountable, and contributions like yours are what keep that work going. We'll review your changes shortly.

If you haven't already, give the contributing guide a quick read: it covers how audits are structured and what we look for in a review.

And if you're finding Fair Code useful or interesting, a star on the repo genuinely helps more people find it - no pressure, just appreciated.

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

@yakew7 @ahmdkaml - new PR touching a path you own, please review.

@ahmdkaml

ahmdkaml commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

the description of the issue requires a regression test but the implementation is ok

@yakew7
yakew7 merged commit e753a37 into yakew7:main Sep 7, 2026
17 of 18 checks passed
yakew7 added a commit that referenced this pull request Sep 7, 2026
…loses #460)

The merged PR's except FileNotFoundError only covered a missing/moved
path; passing a directory instead of a file (IsADirectoryError, a
sibling OSError subclass) still leaked a raw traceback. Widened to
except OSError and used the OS's own strerror so the message stays
accurate for either case ("No such file or directory" vs "Is a
directory") instead of hardcoding "not found" for both. The PR also
shipped with no test coverage of its own - added tests for both the
missing-file and directory cases.
yakew7 added a commit that referenced this pull request Sep 7, 2026
… 2.2.0)

Shreyash0712's #475 (codeowners-access.yml fork guard) and AchieverSana's
#476 (first merged PR, render_terminal_png.py's missing-file handling)
both credited. Snapshot bumped to PR #476; stars/forks/contributors
synced across README's Traction table and METRICS.md.
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.

render_terminal_png.py leaks a raw traceback for a missing input file instead of failing cleanly

3 participants