Skip to content

fix(oracle): Trigger sync invalid#20455

Open
bwcxyk wants to merge 1 commit into
bytebase:mainfrom
bwcxyk:fix
Open

fix(oracle): Trigger sync invalid#20455
bwcxyk wants to merge 1 commit into
bytebase:mainfrom
bwcxyk:fix

Conversation

@bwcxyk

@bwcxyk bwcxyk commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Fix trigger metadata fields to ensure UTF-8 compliance.

Code 13: Internal
[internal] failed to sync database schema for database "instances/mmtest/databases/TEST_USER", error failed to upsert database schema for database "TEST_USER": proto: field bytebase.store.TriggerMetadata.body contains invalid UTF-8

Fix trigger metadata fields to ensure UTF-8 compliance.
@bwcxyk bwcxyk requested a review from a team as a code owner June 1, 2026 06:25
@cla-bot cla-bot Bot added the cla-signed label Jun 1, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e66e49b47

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Name: triggerName.String,
Body: constructTriggerBody(description.String, triggerBody.String),
Name: common.SanitizeUTF8String(triggerName.String),
Body: constructTriggerBody(common.SanitizeUTF8String(description.String), common.SanitizeUTF8String(triggerBody.String)),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve trigger body line breaks when sanitizing

When an Oracle trigger body contains any invalid byte, SanitizeUTF8String takes its slow path and also hex-escapes control characters such as \n and \t (backend/common/util.go). Applying it directly to the SQL body here means multi-line triggers with one bad encoded character get stored with literal \x0a sequences instead of line breaks; in common cases like -- comments this changes the parsed trigger text and makes the generated DDL unusable even though the original problem was only invalid UTF-8. Consider sanitizing only invalid UTF-8 for SQL definitions, or preserving normal whitespace while escaping the bad bytes.

Useful? React with 👍 / 👎.

Name: triggerName.String,
Body: constructTriggerBody(description.String, triggerBody.String),
Name: common.SanitizeUTF8String(triggerName.String),
Body: constructTriggerBody(common.SanitizeUTF8String(description.String), common.SanitizeUTF8String(triggerBody.String)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One concern is TriggerMetadata.Body. It is SQL/PLSQL text, so using common.SanitizeUTF8String() directly may be too aggressive. When that function hits invalid UTF-8, it can also escape normal whitespace like newlines and tabs into \x0a / \x09, which may corrupt multiline trigger definitions.

I suggest keeping the current sanitization for Name, Timing, and Event, but using a narrower sanitizer for Body: replace invalid UTF-8 bytes while preserving normal SQL whitespace such as \n, \r, and \t.

It would also be good to add a regression test for invalid UTF-8 in trigger body, verifying that marshal succeeds and multiline formatting is preserved.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View and Routine likely have the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants