Skip to content

fix: Read input as bytes in MsgSpec Singer message reader#3140

Open
edgarrmondragon wants to merge 1 commit into
mainfrom
edgarrmondragon/fix/msgspec-bytes
Open

fix: Read input as bytes in MsgSpec Singer message reader#3140
edgarrmondragon wants to merge 1 commit into
mainfrom
edgarrmondragon/fix/msgspec-bytes

Conversation

@edgarrmondragon
Copy link
Copy Markdown
Collaborator

@edgarrmondragon edgarrmondragon commented Jun 25, 2025

Summary by Sourcery

Make MsgSpecReader consume raw bytes from stdin by updating its generic parameter, default_input, and deserialize_json signature, and improve error messaging

Bug Fixes:

  • Include repr of the input line in JSON parse error messages

Enhancements:

  • Change MsgSpecReader to use sys.stdin.buffer as default_input
  • Update GenericSingerReader parameter and deserialize_json to handle bytes instead of str

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Jun 25, 2025

Reviewer's Guide

This PR refactors MsgSpecReader to read and deserialize raw bytes from stdin instead of strings and enhances error reporting by formatting failed lines with repr.

Class diagram for updated MsgSpecReader and related methods

classDiagram
    class GenericSingerReader~T~ {
    }
    class MsgSpecReader {
        +default_input: IO[bytes]
        +deserialize_json(line: bytes) dict
    }
    GenericSingerReader <|-- MsgSpecReader
Loading

Class diagram for deserialize_json method signature change

classDiagram
    class MsgSpecReader {
        +deserialize_json(line: bytes) dict
    }
Loading

File-Level Changes

Change Details Files
Support raw bytes input in MsgSpecReader
  • Changed generic type parameter from str to bytes
  • Added default_input property returning sys.stdin.buffer
  • Updated deserialize_json signature to accept bytes
singer_sdk/contrib/msgspec.py
Improve error logging for unparseable lines
  • Logged exception context using logger.exception
  • Formatted the error message with repr(line) via {line!r}
singer_sdk/contrib/msgspec.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

@edgarrmondragon edgarrmondragon self-assigned this Jun 25, 2025
@edgarrmondragon edgarrmondragon added this to the v0.48.0 milestone Jun 25, 2025
@edgarrmondragon edgarrmondragon added the Type/Target Singer targets label Jun 25, 2025
@edgarrmondragon edgarrmondragon marked this pull request as ready for review June 25, 2025 01:39
Copy link
Copy Markdown
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 @edgarrmondragon - I've reviewed your changes and they look great!


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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 25, 2025

Codecov Report

❌ Patch coverage is 83.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.29%. Comparing base (e753b8d) to head (48cc3d4).
⚠️ Report is 78 commits behind head on main.

Files with missing lines Patch % Lines
singer_sdk/contrib/msgspec.py 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3140      +/-   ##
==========================================
- Coverage   92.30%   92.29%   -0.02%     
==========================================
  Files          63       63              
  Lines        5343     5345       +2     
  Branches      677      677              
==========================================
+ Hits         4932     4933       +1     
- Misses        290      291       +1     
  Partials      121      121              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Jun 25, 2025

CodSpeed Performance Report

Merging #3140 will not alter performance

Comparing edgarrmondragon/fix/msgspec-bytes (48cc3d4) with main (e753b8d)

Summary

✅ 8 untouched benchmarks

@edgarrmondragon edgarrmondragon force-pushed the edgarrmondragon/fix/msgspec-bytes branch from fc3272f to 48cc3d4 Compare June 26, 2025 00:37
@edgarrmondragon edgarrmondragon removed this from the v0.48 milestone Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type/Target Singer targets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant