Skip to content

Exception clause for detecting editable packages will silently catch all exceptions #353

@RRosio

Description

@RRosio

The code that identifies packages installed in editable/dev mode currently catches all exceptions, and continues on with an empty set for dev/editable packages if it encounters and error. While this is not a crucial enhancement, it might be worth exploring potential issues that we should handle.


[nitpick] The broad exception clause except (json.JSONDecodeError, Exception): will silently catch all exceptions, including unexpected errors like TypeError, AttributeError, or KeyError that might indicate bugs. This makes debugging difficult.

Consider being more specific about which exceptions to catch, or at least log the exception:

except json.JSONDecodeError as e:
    self.log.warning(f"Failed to parse pip editable packages JSON: {e}")
except Exception as e:
    self.log.warning(f"Failed to get pip editable packages: {e}")
                except json.JSONDecodeError as e:
                    self.log.warning(f"Failed to parse pip editable packages JSON: {e}")
                except Exception as e:
                    self.log.warning(f"Failed to get pip editable packages: {e}")

Originally posted by @Copilot in #352 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions