Description
In CDS 10 the consistent_params compat flag is removed and its behavior — req.params is always an array of objects — becomes the permanent, non-configurable default. Previously, projects that had not yet opted in via cds.features.consistent_params: true could still receive req.params entries as primitives for single-key entities. Any code that treats req.params[i] as a primitive (a plain string or number) will now receive an object instead, causing unexpected behaviour or runtime errors. Code that already accesses req.params[i].KeyField is unaffected.
How to Check
- [ ] Search for
cds.features.consistent_paramsinpackage.json,.cdsrc.json, and environment-specific config files — remove it regardless of value. - [ ] Run the
pattern_astpatterns to find allreq.params[i]accesses andconst [x] = req.paramsdestructuring. - [ ] For each match, verify whether the element is subsequently used as a primitive (e.g. passed to
===, used in a template literal without.KeyField, or inserted directly into a query). - [ ] Check test assertions that compare
req.params[0]to a scalar value.
Migration Steps
Remove the
consistent_paramsflag from CDS configuration:diff// package.json or .cdsrc.json "cds": { "features": { - "consistent_params": true } }Update code that treats
req.paramsentries as primitives to access the key field explicitly:diff- const id = req.params[0]; // was a primitive string/number + const { ID } = req.params[0]; // always an object now const book = await db.read(Books, id);Update array-destructuring patterns:
diff- const [id] = req.params; + const [{ ID: id }] = req.params;Update test assertions that compare params entries to scalar values:
diff- expect(req.params[0]).toBe('42'); + expect(req.params[0]).toEqual({ ID: '42' });