u
This commit is contained in:
@@ -81,6 +81,13 @@ function articleErrorStatus(error) {
|
||||
if (error.message === 'Attribute name not found') return 404;
|
||||
if (error.message === 'attributeNameId is required to become a parent article') return 400;
|
||||
if (error.message?.includes('already used by an ancestor parent')) return 400;
|
||||
// Variant-parent preconditions: a parent article may not carry stock,
|
||||
// suppliers, a Stückliste or options. These are user-correctable 409s,
|
||||
// not server faults — without these the route returns a bare 500.
|
||||
if (error.message === 'An article with existing stock cannot become a parent article') return 409;
|
||||
if (error.message === 'An article with assigned suppliers cannot become a parent article') return 409;
|
||||
if (error.message === 'A Stückliste article cannot become a parent') return 409;
|
||||
if (error.message === 'An article with options cannot become a parent') return 409;
|
||||
if (error.message?.includes('cannot have attribute values for its variant attribute')) return 400;
|
||||
if (error.message?.includes('A parent article cannot have') || error.message?.includes('parent article cannot have')) return 400;
|
||||
if (error.message === 'Cannot disable parent mode on an article that still has children') return 400;
|
||||
@@ -1855,9 +1862,12 @@ export function register(app, basePath = '') {
|
||||
* $ref: '#/components/schemas/Article'
|
||||
* 400:
|
||||
* description: |
|
||||
* Invalid input, `attributeNameId` missing while `isParent` is true, article still
|
||||
* has children, article has stock/suppliers/a Stückliste/options, or the attribute is
|
||||
* already used by an ancestor parent article.
|
||||
* Invalid input — `attributeNameId` missing while `isParent` is true, article still
|
||||
* has children (disabling), or the attribute is already used by an ancestor parent.
|
||||
* 409:
|
||||
* description: |
|
||||
* Article state conflicts with becoming a variant parent — it still has stock,
|
||||
* assigned suppliers, a Stückliste, or options. Clear these first.
|
||||
* 404:
|
||||
* description: Article or attribute name not found
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user