Skip to content

Narrow two broad exception handlers in the SourceHut adapter #953

Closed

Description

@justinmclean

Summary

Two except Exception handlers in tools/sourcehut/ swallow every error,
including ones that should surface. Narrow them to the exceptions actually
expected.

Background

CodeQL flagged both as empty-except. The concrete risk is a silently wrong
result rather than a crash: an unexpected error is discarded and the caller
carries on with incomplete data.

Where to look

  • tools/sourcehut/src/magpie_sourcehut/client.py line 82 - the handler around
    parsing an HTTP error body is except Exception: with a comment and pass.
    Only JSON-decoding failures are expected here, so
    (json.JSONDecodeError, KeyError, TypeError) is the intended set.
  • tools/sourcehut/src/magpie_sourcehut/lists.py line 125 -
    contextlib.suppress(Exception) around a sort. If the sort fails, emails[0]
    is still used as the cover letter, so a malformed node silently yields the
    wrong description and author. (TypeError, AttributeError) is the expected
    set.

Acceptance criteria

  • Both handlers name the exceptions they expect.
  • An unexpected exception propagates rather than being discarded.
  • A test covers the expected-failure path for at least one of the two.
  • uv run --directory tools/sourcehut --group dev pytest passes.

Estimated effort

~2 hours for someone new to the codebase.

Getting started

New to Magpie? Start with
Your first contribution.

Note: this issue was drafted by an AI-assisted mentoring tool and may contain
mistakes. A Magpie maintainer, a real person, will be the next to engage on it.
If something here looks wrong or unclear, please say so on the issue and a
maintainer will follow up. See
CONTRIBUTING.md
for how Magpie handles contributions.

Activity

  1. amh1k commented on Jul 27, 2026

    @amh1k
    Contributor

    Would like to claim this issue

  2. justinmclean commented on Jul 27, 2026

    @justinmclean
    MemberAuthor

    Thanks @amh1k it's all yours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

good first issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions