Skip to content
Snippets Groups Projects

Ensure errors.css is interpreted as UTF-8 encoding

Merged Stan Hu requested to merge sh-force-errors-css-utf-8 into master

What does this MR do and why?

Since gitlab-foss!19096 (merged), we've inlined the errors.css by directly including the Sprockets assets into the HAML. This worked fine as long as the CSS file remained as a plain ASCII file. However, the switch to the new CSS pipeline with !144479 (merged) appears to have introduced a single UTF-8 character. Since Sprockets loads the asset via File.binread (https://github.com/rails/sprockets/blob/d1dcf7075c468522e1cb6f93ae547d8d7fdcfbcb/lib/sprockets/asset.rb#L99), the contents of this UTF-8 file is forced as ASCII-8BIT. When this ASCII-8BIT string is combined with other UTF-8 characters, such as Chinese characters, the encoding fails with a 500 error: incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError).

To work around this issue, we force the encoding to UTF-8 to ensure the error page can render.

Relates to gitlab-com/gl-infra/production#17627 (closed)

Edited by Stan Hu

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • I have confirmed locally that this fixes the problem.

  • Heinrich Lee Yu approved this merge request

    approved this merge request

    • Resolved by Stan Hu

      :wave: @engwan, thanks for approving this merge request.

      This is the first time the merge request has been approved. To ensure we don't only run predictive pipelines, and we don't break master, a new pipeline will be started shortly.

      Please wait for the pipeline to start before resolving this discussion and set auto-merge for the new pipeline. See merging a merge request for more details.

  • Heinrich Lee Yu removed review request for @engwan

    removed review request for @engwan

  • Heinrich Lee Yu mentioned in merge request !145355 (closed)

    mentioned in merge request !145355 (closed)

  • Stan Hu changed the description

    changed the description

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading