fix(api): normalize + truncate commitMessage to 255 chars to prevent varchar(255) DB error #35
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.
Description
Fix an upload/rollback failure caused by overly long
commitMessagevalues being written intoreleases.commit_message (varchar(255)), which triggered the database error:value too long for type character varying(255).The API now normalizes whitespace and safely truncates
commitMessageto 255 Unicode characters before creating a release record.DB error:
Upload error: error: value too long for type character varying(255) at async h.createRelease (.next/server/pages/api/tracking/[release_id].js:26:96) at async q (.next/server/pages/api/upload.js:33:8799) at async Module.m (.next/server/pages/api/upload.js:33:12170) { length: 99, severity: 'ERROR', code: '22001', detail: undefined, hint: undefined, position: undefined, internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'varchar.c', line: '632', routine: 'varchar' }Type of change
For Bug Fixes
Describe the bug
When the git commit message is long (e.g., multi-line body or >255 characters), the upload flow passes it through and the backend attempts to store it in
releases.commit_message(limited to 255 chars), causing the DB insert to fail and the request to error.Steps to reproduce
/api/uploadwithcommitMessage)value too long for type character varying(255)Expected behavior
Upload/rollback succeeds and a release record is created even if the commit message is long.
Actual behavior
The DB insert fails due to
commit_messageexceedingvarchar(255), causing upload/rollback to fail.Testing
npm test(Jest): all tests passed (6 suites / 24 tests / 17 snapshots)Checklist