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 GraphQL IDE charset error #3824

Merged
merged 4 commits into from
Mar 28, 2025
Merged

Conversation

moritz89
Copy link
Contributor

@moritz89 moritz89 commented Mar 28, 2025

Description

Why:

  • Hide non-printing characters

This change addresses the need by:

  • Explicitly setting the content-type charset to utf-8

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Summary by Sourcery

Bug Fixes:

  • Resolve potential character encoding issues by explicitly setting the content type charset to UTF-8 in the GraphQL IDE handler

Why:

- Hide non-printing characters

This change addresses the need by:

- Explicitly setting the content-type charset to utf-8
Copy link
Contributor

sourcery-ai bot commented Mar 28, 2025

Reviewer's Guide by Sourcery

This pull request fixes a character encoding issue in the GraphQL IDE by explicitly setting the content type charset to utf-8. This ensures that non-printing characters are properly handled.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Set the content type charset to utf-8 for the GraphQL IDE response.
  • Set the content_type to text/html; charset=utf-8.
strawberry/channels/handlers/http_handler.py

Possibly linked issues


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!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

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 @moritz89 - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Thanks for fixing this bug, explicitly setting the charset is the right approach.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

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.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This PR updates the async GraphQL IDE in http_handler.py to explicitly set the content-type header to "text/html; charset=utf-8", addressing formatting errors seen in GraphiQL (#3821).

  • In strawberry/channels/handlers/http_handler.py, render_graphql_ide() now returns "text/html; charset=utf-8" for async IDE responses.
  • The change resolves hidden character issues in GraphiQL without impacting other functionalities, though sync consumers remain unchanged.

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

@botberry
Copy link
Member

botberry commented Mar 28, 2025

Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:


Fix GraphQL IDE charset error that showed non-printing characters.

Here's the tweet text:

🆕 Release (next) is out! Thanks to @moritz89 for the PR 👏

Get it here 👉 https://strawberry.rocks/release/(next)

Copy link

codecov bot commented Mar 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.24%. Comparing base (de07ab6) to head (075d223).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3824   +/-   ##
=======================================
  Coverage   95.24%   95.24%           
=======================================
  Files         499      499           
  Lines       32417    32417           
  Branches     1681     1681           
=======================================
  Hits        30877    30877           
  Misses       1275     1275           
  Partials      265      265           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

codspeed-hq bot commented Mar 28, 2025

CodSpeed Performance Report

Merging #3824 will not alter performance

Comparing moritz89:main (075d223) with main (0d9ffa5)

Summary

✅ 21 untouched benchmarks

@moritz89
Copy link
Contributor Author

PR Summary

This PR updates the async GraphQL IDE in http_handler.py to explicitly set the content-type header to "text/html; charset=utf-8", addressing formatting errors seen in GraphiQL (#3821).

* In strawberry/channels/handlers/http_handler.py, render_graphql_ide() now returns "text/html; charset=utf-8" for async IDE responses.

* The change resolves hidden character issues in GraphiQL without impacting other functionalities, though sync consumers remain unchanged.

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

1 file(s) reviewed, no comment(s) Edit PR Review Bot Settings | Greptile

Updated MR to handle sync consumer as well

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

(updates since last review)

This PR fixes the GraphQL IDE charset issue in http_handler.py by explicitly setting the content-type header to "text/html; charset=utf-8", eliminating hidden characters in GraphiQL.

  • Modified /strawberry/channels/handlers/http_handler.py: render_graphql_ide now returns "text/html; charset=utf-8".
  • Applies change consistently for both async and sync GraphQLHTTPConsumer handlers.
  • Resolves the formatting error reported in issue Partial content-type results in GraphiQL formatting errors #3821 with minimal impact on existing functionality.

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link
Member

@patrick91 patrick91 left a comment

Choose a reason for hiding this comment

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

thank you so much!

do you want to add a RELEASE.md file so we ship this? :D

@patrick91 patrick91 enabled auto-merge (squash) March 28, 2025 16:39
@patrick91 patrick91 merged commit 31aec15 into strawberry-graphql:main Mar 28, 2025
95 of 97 checks passed
amlimaye pushed a commit to Tyba-Energy/strawberry that referenced this pull request Mar 31, 2025
* Fix GraphQL IDE charset error

Why:

- Hide non-printing characters

This change addresses the need by:

- Explicitly setting the content-type charset to utf-8

* Include sync http consumer

* Add release file

* Update RELEASE.md

---------

Co-authored-by: Patrick Arminio <patrick.arminio@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants