Repository navigation
Conversation
type_mappings and remotelink_repo_pattern of _tool_jira_scope_configs were created from json.RawMessage and became bytea on PostgreSQL, while the model writes them as JSON text. PostgreSQL parses that text as bytea escape input, so saving a remote link pattern (its generated regex contains backslashes such as \S+) fails with "invalid input syntax for type bytea (SQLSTATE 22P02)". Convert both columns to json on PostgreSQL; empty values become NULL. MySQL is not affected and left unchanged. Fixes apache#8275 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: DoDiODev <DoDiDev@proton.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On PostgreSQL, saving a Jira scope config with a remote link pattern
(Cross-domain → Connect Jira issues and commits via Jira issues' remote
links …) fails:
type_mappingsandremotelink_repo_patternof_tool_jira_scope_configswere created from
json.RawMessage(20220716_add_init_tables,20230223_add_repo_pattern) and therefore becamebyteaon PostgreSQL. Thecurrent model writes both with
gorm:"type:json;serializer:json", i.e. asJSON text. PostgreSQL parses that text as
byteaescape input, so anybackslash breaks it — and the regex generated by
/plugins/jira/generate-regexalways contains
\S+and\w{40}.type_mappingsonly works by accidentbecause it contains no backslashes.
This PR adds a migration that converts both columns to
jsonon PostgreSQL(
convert_from(col, 'UTF8')::json; empty values left by20230609_clear_repo_patternbecomeNULL). It only runs when the columnsare still
bytea. MySQL (longblob) is not affected and left unchanged.Does this close any open issues?
Closes #8275 (closed as stale, still reproducible on
main).Screenshots
n/a
Other Information
Verified manually against a fresh PostgreSQL 18 with
go run server/main.go:POST /plugins/jira/connections/1/scope-configswith aremote link pattern → 500
invalid input syntax for type bytea;json, existing rows(NULL, empty, valid JSON) are preserved,
POST/PATCHwith the patternreturn 200 and
GETreturns pattern and type mappings unchanged.Also applied to an existing PostgreSQL instance with real Jira data: the
migration converted both columns, and all remote link patterns could then be
saved through the config UI.
gofmt,go vetandmake migration-script-lintpass. CI on the fork(same jobs as upstream, PostgreSQL 18.7 / MySQL 8.4):
https://github.com/DoDiODev/devlake/actions/runs/44511264970 (16/16 green).