Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle empty 2xx responses #40

Merged
merged 2 commits into from
Jan 31, 2025

Conversation

devin-ai-integration[bot]
Copy link
Contributor

This PR adds a check to ensure empty successful responses don't cause JSON deserialization errors.

Changes

Modified the request method in Connection class to check for response content before attempting JSON deserialization:

if r.ok:
    if r.content and len(r.content) > 0:
        try:
            return r.json()
        except JSONDecodeError:
            return None
    return None

This change specifically addresses endpoints like users.delete() that return a 2xx response without a body, preventing unnecessary JSON decode errors while maintaining the existing behavior for responses with content.

Link to Devin run: https://app.devin.ai/sessions/70fbcf177d2747d4bf61393c76788909

Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add "(aside)" to your comment to have me ignore it.
  • Look at CI failures and help fix them

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@cellomatt cellomatt requested a review from cjbell January 30, 2025 22:24
@cellomatt cellomatt requested review from a team, mattmikolay and JEverhart383 and removed request for a team January 30, 2025 23:33
Copy link

@mattmikolay mattmikolay left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me!

@cellomatt cellomatt merged commit 6c1b7e0 into main Jan 31, 2025
1 check passed
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.

None yet

3 participants