indigo-iam / iam

INDIGO Identity and Access Management Service
https://indigo-iam.github.io/
Other
102 stars 43 forks source link

Java SQL incorrect string value #700

Closed zhangxt-ihep closed 1 month ago

zhangxt-ihep commented 8 months ago

Hi,

This problem exists at v1.8.2p2 and v1.8.3. When using IAM as an IdP to login a SP, user can choose Institute of High Energy Physiscs (IHEP) SAML server to emit users identities. It returns error code of 500 and the error is:

Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.9.v20210604-2c549e2208): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Incorrect string value: '\xE5\x94\x90\xE5\xBF\x97...' for column 'info_val' at row 1 Error Code: 1366 Call: INSERT INTO saved_user_auth_info (owner_id, info_val, info_key) VALUES (?, ?, ?) bind => [3 parameters bound] Query: DataModifyQuery(sql="INSERT INTO saved_user_auth_info (owner_id, info_val, info_key) VALUES (?, ?, ?)"); nested exception is javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.9.v20210604-2c549e2208): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Incorrect string value: '\xE5\x94\x90\xE5\xBF\x97...' for column 'info_val' at row 1 Error Code: 1366 Call: INSERT INTO saved_user_auth_info (owner_id, info_val, info_key) VALUES (?, ?, ?) bind => [3 parameters bound] Query: DataModifyQuery(sql="INSERT INTO saved_user_auth_info (owner_id, info_val, info_key) VALUES (?, ?, ?)")

We guess it is caused by the Chinese character insertion issues. The value '\xE5\x94\x90\xE5\xBF\x97...' is the name of our user with Chinese characters in UTF-8 format which is emitted by IHEP IdP. I suggest the IAM database container defaultly turns on the support of utf-8.

Reference: https://stackoverflow.com/questions/10957238/incorrect-string-value-when-trying-to-insert-utf-8-into-mysql-via-jdbc https://stackoverflow.com/questions/23670754/exception-java-sql-sqlexception-incorrect-string-value-xf0-x9f-x92-xbc-for

Thanks.

rmiccoli commented 8 months ago

PR #701