Skip to content

fix: narrow broad Exception in banktransfer CSV hint import#2764

Closed
MEGHANA660 wants to merge 2 commits intofossasia:devfrom
MEGHANA660:fix/narrow-exception-in-banktransfer-csv-hint
Closed

fix: narrow broad Exception in banktransfer CSV hint import#2764
MEGHANA660 wants to merge 2 commits intofossasia:devfrom
MEGHANA660:fix/narrow-exception-in-banktransfer-csv-hint

Conversation

@MEGHANA660
Copy link

@MEGHANA660 MEGHANA660 commented Mar 14, 2026

Problem

process_csv_hint() in banktransfer/views.py had a broad
except Exception with a TODO to narrow it down.

Fix

Replaced with except (ValueError, TypeError) which covers
the realistic failure cases when saving CSV hint settings.
Also removed the redundant pass statement.

Changes

  • app/eventyay/plugins/banktransfer/views.py: Narrowed
    broad exception in process_csv_hint()

Summary by Sourcery

Narrow exception handling for CSV hint processing in the bank transfer plugin to handle only expected errors when saving settings.

Bug Fixes:

  • Restrict CSV hint settings import error handling to ValueError and TypeError instead of catching all exceptions.

Enhancements:

  • Remove redundant code in CSV hint processing after tightening exception handling.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Mar 14, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Narrowed a previously broad except Exception in the bank transfer CSV hint import flow to specific ValueError and TypeError handling, and cleaned up redundant code in the same block.

File-Level Changes

Change Details Files
Narrow exception handling in CSV hint processing to specific error types and remove redundant pass.
  • Change the catch-all exception handler when saving banktransfer_csvhint settings to only catch ValueError and TypeError
  • Retain error logging on failure while ensuring only expected errors are swallowed and logged
  • Remove a no-op pass statement from the exception block for cleaner control flow
app/eventyay/plugins/banktransfer/views.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Consider using logger.exception (or logger.error(..., exc_info=True)) in the exception handler so that the traceback is preserved for easier debugging while still narrowing the caught exception types.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider using `logger.exception` (or `logger.error(..., exc_info=True)`) in the exception handler so that the traceback is preserved for easier debugging while still narrowing the caught exception types.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Rachit7168
Copy link
Contributor

Link the issue this PR solve in the description

@mariobehling
Copy link
Member

Thanks for your contribution and for looking into this cleanup.

We are closing this PR for now because there is no linked issue describing a concrete bug, use case, or expected behavior.

I reviewed the actual diff. This PR only changes the exception handling in process_csv_hint() in app/eventyay/plugins/banktransfer/views.py by replacing a broad except Exception with except (ValueError, TypeError) and switching the logging call to logger.exception(...).

While narrowing broad exception handling can be a good improvement in principle, in this case there is no issue documenting:

  • what concrete failure is being solved
  • whether ValueError and TypeError are really the only expected exceptions here
  • what behavior should happen if other import related failures occur

Without that context, this becomes a speculative cleanup rather than an issue-driven fix, and it is difficult to review safely.

Please feel welcome to open an issue first describing the exact problem and expected outcome. After that, a new focused PR linked to the issue would be much easier to review and merge.

Thanks again for the effort and looking forward to a follow-up contribution.

@github-project-automation github-project-automation bot moved this from Backlog to Done in Eventyay Next Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants