mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-31 00:16:47 +01:00
0d3dee0e96
https://linear.app/unleash/issue/2-2453/validate-patched-data-against-schema This adds schema validation to patched data, fixing potential issues of patching data to an invalid state. This can be easily reproduced by patching a strategy constraints to be an object (invalid), instead of an array (valid): ```sh curl -X 'PATCH' \ 'http://localhost:4242/api/admin/projects/default/features/test/environments/development/strategies/8cb3fec6-c40a-45f7-8be0-138c5aaa5263' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '[ { "path": "/constraints", "op": "replace", "from": "/constraints", "value": {} } ]' ``` Unleash will accept this because there's no validation that the patched data actually looks like a proper strategy, and we'll start seeing Unleash errors due to the invalid state. This PR adapts some of our existing logic in the way we handle validation errors to support any dynamic object. This way we can perform schema validation with any object and still get the benefits of our existing validation error handling. This PR also takes the liberty to expose the full instancePath as propertyName, instead of only the path's last section. We believe this has more upsides than downsides, especially now that we support the validation of any type of object. ![image](https://github.com/user-attachments/assets/f6503261-f6b5-4e1d-9ec3-66547d0d061f) |
||
---|---|---|
.. | ||
archivedfeature-error.ts | ||
bad-data-error.ts | ||
content-type-error.ts | ||
db-error.ts | ||
disabled-error.ts | ||
exceeds-limit-error.test.ts | ||
exceeds-limit-error.ts | ||
feature-has-tag-error.ts | ||
forbidden-error.ts | ||
from-legacy-error.ts | ||
incompatible-project-error.ts | ||
index.ts | ||
invalid-operation-error.ts | ||
invalid-token-error.ts | ||
minimum-one-environment-error.ts | ||
name-exists-error.ts | ||
not-implemented-error.ts | ||
notfound-error.ts | ||
operation-denied-error.ts | ||
owasp-validation-error.ts | ||
password-mismatch.ts | ||
password-previously-used.ts | ||
password-undefined.ts | ||
pattern-error.ts | ||
permission-error.ts | ||
project-without-owner-error.ts | ||
rate-limit-error.ts | ||
role-in-use-error.ts | ||
unauthorized-error.ts | ||
unleash-error.test.ts | ||
unleash-error.ts | ||
used-token-error.ts |