You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Over-long snapshot name 500s with the raw database error #8576
PUT /api/v1/snapshots/:id with a name longer than 255 characters returns:
500 value too long for type character varying(255)
The raw driver error goes straight to the caller. ProjectSnapshot.name is a DataTypes.STRING, so VARCHAR(255), and updateSnapshot in forge/db/controllers/Snapshot.js checks only that the name isn't blank:
if(hasProperty(options,'name')&&(typeofoptions.name!=='string'||options.name.trim()==='')){thrownewValidationError('Snapshot name is required')}
255 characters works, 256 doesn't. Same story for the blank name just above it, which throws a sequelize ValidationError that nothing maps to a status code, so that one also comes back as a 500 (500 Snapshot name is required).
Worth knowing this only bites on postgres. SQLite ignores the declared column width, so on the default dev database an over-long name just saves, and a unit test on that backend wouldn't catch it.
Probably wants a length check next to the blank check, and both mapped to a 400 rather than falling through to the error handler. Related to #8568, which is the same shape of thing on the import route.
Also worth a thought: the name is validated trimmed but stored untrimmed, so " padded " is accepted and kept with the padding, which renders identically to "padded" in most places.
Activity
Bound the snapshot name in the update tool