Description
With CDS 10, Declarative Constraints become generally available and their error codes are standardized. During the preview phase, error codes for constraint violations (such as ASSERT_NOT_NULL, ASSERT_UNIQUE, ASSERT_FORMAT) may have had different values or formats than the GA codes. Application code that compares or matches against these error code strings in catch blocks or test assertions must be updated to the new standardized values. No CDL or service handler changes are required — the constraint declarations themselves remain valid.
How to Check
- [ ] Search for string literals
'ASSERT_NOT_NULL','ASSERT_UNIQUE','ASSERT_FORMAT'in catch blocks, error handler functions, and test assertion code. - [ ] Search for
err.code,error.code, ore.codecomparisons in service handlers and integration tests. - [ ] Check test files for
expect(err.code).toBe(...)orassert.equal(err.code, ...)patterns referencing constraint-related error codes. - [ ] Check for any string-based switch/case statements branching on error codes.
Migration Steps
Update error code comparisons in catch blocks to the GA values. Verify the exact new code values from the CDS 10 release notes and update accordingly:
difftry { await srv.create(Orders).entries(data); } catch (err) { - if (err.code === 'ASSERT_NOT_NULL') { + if (err.code === '400') { // or the new standardized code per release notes req.error(400, 'Missing required field'); } }Update Jest test assertions that check constraint error codes:
diffawait expect(srv.create(Books).entries({ title: null })) .rejects.toMatchObject({ - code: 'ASSERT_NOT_NULL', + code: '400', // verify the exact GA code in the release notes });Update any switch/case branches on error code strings:
diffswitch (err.code) { - case 'ASSERT_UNIQUE': + case '<new-ga-code>': // replace with actual GA code return req.error(409, 'Duplicate entry'); }
Notes
Verify the exact GA error code values from the CDS 10 release notes before updating assertions. The standardization may consolidate multiple preview codes into a smaller set or align them with HTTP status codes. Running the test suite against a CDS 10 installation and observing actual error code values is the most reliable approach.