Skip to content

Mysql behaves differently to Postgresql when using emoji in app name #3722

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

Closed
kathap opened this issue Apr 4, 2024 · 2 comments
Closed

Mysql behaves differently to Postgresql when using emoji in app name #3722

kathap opened this issue Apr 4, 2024 · 2 comments

Comments

@kathap
Copy link
Contributor

kathap commented Apr 4, 2024

Issue

Mysql throws an error while trying to store a string into a varchar column when the string contains emojis. E.G. if you give an app the name '🦄🦄🦄'.
(You can see the error in the Unit Tests / Test-Mysql checks of this PR #3719 )

Context

This is inconsistent to Postgresql behaviour, Postgresql does not throw an error and stores the name as it is into the ccdb.
The column name in table apps is varchar(255).

Steps to Reproduce

  1. Insert into e.g. spec/request/space_manifests_spec.rb a test that creates an app with emoji in the app name e.g.
context 'when the manifest contains valid binary-encoded URL(s) for the buildpack(s)' do
      let(:app1_model) { VCAP::CloudController::AppModel.make(name: '🦄🦄🦄', space: space) }
      let(:yml_manifest_with_binary_valid_buildpacks) do
        "---
            applications:
            - name: #{app1_model.name}
              buildpacks:
              - !!binary |-
                  aHR0cHM6Ly9naXRodWIuY29tL2Nsb3VkZm91bmRyeS9uZ2lueC1idWlsZHBhY2suZ2l0
              - !!binary |-
                  aHR0cHM6Ly9naXRodWIuY29tL2J1aWxkcGFja3MvbXktc3BlY2lhbC1idWlsZHBhY2s="
      end

      it 'applies the manifest' do
        post "/v3/spaces/#{space.guid}/actions/apply_manifest", yml_manifest_with_binary_valid_buildpacks, yml_headers(user_header)
        expect(last_response.status).to eq(202)
      end
    end
  1. and execute the test against mysql
brew services start mysql
export DB=mysql
export DB_CONNECTION_STRING=mysql2://root:@127.0.0.1:3306/cc_test
bundle exec rake db:create

bundle exec rspec spec/request/space_manifests_spec.rb  

Expected result

All tests pass.

Current result

The test with the emojis in the app name fails with following error:

  1) Space Manifests POST /v3/spaces/:guid/actions/apply_manifest when the manifest contains valid binary-encoded URL(s) for the buildpack(s) applies the manifest
     Failure/Error: buildpack_lifecycle_data { BuildpackLifecycleDataModel.make(app: object.save) }
     
     Sequel::DatabaseError:
       Mysql2::Error: Incorrect string value: '\xF0\x9F\xA6\x84\xF0\x9F...' for column 'name' at row 1
     # ./spec/support/fakes/blueprints.rb:50:in `block (2 levels) in <module:CloudController>'
     # ./spec/support/fakes/blueprints.rb:50:in `block in <module:CloudController>'
     # ./spec/request/space_manifests_spec.rb:223:in `block (4 levels) in <top (required)>'
     # ./spec/request/space_manifests_spec.rb:20:in `block (3 levels) in <top (required)>'
     # ./spec/spec_helper.rb:191:in `block (4 levels) in <top (required)>'
     # ./spec/support/database_isolation.rb:37:in `cleanly'
     # ./spec/spec_helper.rb:191:in `block (3 levels) in <top (required)>'
     # /Users/I546390/.rbenv/versions/3.2.3/bin/bundle:25:in `load'
     # /Users/I546390/.rbenv/versions/3.2.3/bin/bundle:25:in `<main>'
     # ------------------
     # --- Caused by: ---
     # Mysql2::Error:
     #   Incorrect string value: '\xF0\x9F\xA6\x84\xF0\x9F...' for column 'name' at row 1
     #   ./spec/support/fakes/blueprints.rb:50:in `block (2 levels) in <module:CloudController>'

Possible Fix

Suggestion/Question: App naming (or storing any value into a varchar column in the ccdb) should be consistent for Mysql and Postgresql.

@moleske
Copy link
Member

moleske commented Apr 4, 2024

Old issue (still open) with comments about emoji not working with mysql
#1375

@kathap
Copy link
Contributor Author

kathap commented Apr 8, 2024

Ah, you are right, must have overseen it, sorry, will close this one 👍

@kathap kathap closed this as completed Apr 8, 2024
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

No branches or pull requests

2 participants