kostas-petrakis opened a new issue, #8275:
URL: https://github.com/apache/incubator-devlake/issues/8275

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and 
found no similar issues.
   
   
   ### What happened
   
   When using PostgreSQL and adding the Cross-domain pattern for Jira GORM 
fails to store the `Regex` field under PostgreSQL (works for MySQL).
   The reason is the field type used (`bytea`) and the safe escaping (?) of the 
string when saving to PostgreSQL, the operation is successful if the user omits 
the `Regex` (tested by overriding the value).
   If I use the following pattern:
   
   ```
   https://github.com/{namespace}/{repo_name}/commit/{commit_sha}
   ```
   
   The following error is produced:
   
   ```shell
   ERROR: invalid input syntax for type bytea (SQLSTATE 
22P02)\n\x1b[0m\x1b[33m[0.710ms] \x1b[34;1m[rows:0]\x1b[0m UPDATE 
\"_tool_jira_scope_configs\" SET \"created_at\"='2024-12-10 
12:49:55.974',\"updated_at\"='2025-01-20 
18:50:53.826',\"entities\"='[\"TICKET\",\"CROSS\"]',\"connection_id\"=1,\"name\"='team-test-jira-config',\"epic_key_field\"='',\"story_point_field\"='customfield_11252',\"remotelink_commit_sha_pattern\"='',\"remotelink_repo_pattern\"='[{\"pattern\":\"https://github.com/{namespace}/{repo_name}/commit/{commit_sha}\",\"regex\":\"https://github.com/(?P\\u003cnamespace\\u003e\\\\S+)/(?P\\u003crepo_name\\u003e\\\\S+)/commit/(?P\\u003ccommit_sha\\u003e\\\\w{40})\"}]',\"type_mappings\"='{\"Backend\":{\"standardType\":\"REQUIREMENT\",\"statusMappings\":null},\"Frontend\":{\"standardType\":\"REQUIREMENT\",\"statusMappings\":null},\"Story\":
   
{\"standardType\":\"REQUIREMENT\",\"statusMappings\":null},\"Subtask\":{\"standardType\":\"REQUIREMENT\",\"statusMappings\":null},\"Task\":{\"standardType\":\"REQUIREMENT\",\"statusMappings\":null}}',\"application_type\"=''
 WHERE \"id\" = 1"
   time="2025-01-20 18:50:53" level=error msg="HTTP 500 error\n\tcaused by: 
ERROR: invalid input syntax for type bytea (SQLSTATE 22P02) (500)\n\tWraps: (2) 
ERROR: invalid input syntax for type bytea (SQLSTATE 22P02)\n\tError types: (1) 
*hintdetail.withDetail (2) *pgconn.PgError"
   ```
   
   
   ### What do you expect to happen
   
   The `Regex` is properly saved for both MySQL and PostgreSQL databases.
   
   ### How to reproduce
   
   Spin up Apache Devlake with PostgreSQL, add a Jira integration with 
Cross-Domain and add a pattern.
   
   ### Anything else
   
   Any suggestions how to solve this would be more than welcome, currently 
looking into a solution using `BeforeUpdate` GORM hook, in order to see if the 
regex pattern can be actually properly transformed for PostgreSQL.
   
   ### Version
   
   31dacd8d42ce33470e09a8fbea02448a0b2a127f
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@devlake.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to