Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce input validation against schema for patching object attributes #5696

Closed
labo-flg opened this issue Jan 25, 2024 · 1 comment
Closed
Assignees
Labels
feature use for describing a new feature to develop solved use to identify issue that has been solved (must be linked to the solving PR)
Milestone

Comments

@labo-flg
Copy link
Member

labo-flg commented Jan 25, 2024

Problem

This issue appeared with the new schema definition introduced with #5392.
Patching attributes with editField was previously validated with json schema, which has been removed.

This is not an issue 99% of the time... but we introduced a new use case in #4304 : a non-multiple object attribute.

This kind of object can be updated with either a complete payload, such as

{
  "id": "4b762ee9-b2da-49fe-99d7-dfd6b9e1fe33",
  "input": {
    "key": "user_confidence_level",
    "value": {
      "max_confidence": 50,
      "overrides": []
  }
}

... or a partial "patch" update like

{
  "id": "4b762ee9-b2da-49fe-99d7-dfd6b9e1fe33",
  "input": {
    "key": "user_confidence_level",
    "object_path": "/user_confidence_level/max_confidence",
    "value": 50
}

However, nothing prevents the user from sending a complete update with a partial object, such as:

{
  "id": "4b762ee9-b2da-49fe-99d7-dfd6b9e1fe33",
  "input": {
    "key": "user_confidence_level",
    "value": {
      "max_confidence": 50,
    }
  }
}

This would still be valid for elastic, and there is no way of preventing this on elastic side (no concept of mandatory field).
The consequences are bad: the object is now partial in DB, but shall be complete for GQL (in my example, overrides cannot be null)

Solution

Enforce a validation against the schema when editing an object field.

This can be done at the earliest time (resolver) or at the bottom of the chain (just before elastic query). TBD.
-> done just before indexing, when the payload is ready.

@labo-flg
Copy link
Member Author

Completed with #6046

@SamuelHassine SamuelHassine added the solved use to identify issue that has been solved (must be linked to the solving PR) label Mar 11, 2024
Archidoit pushed a commit that referenced this issue Jun 6, 2024
…indexing (#5696)

Co-authored-by: Landry Trebon <landry.trebon@filigran.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature use for describing a new feature to develop solved use to identify issue that has been solved (must be linked to the solving PR)
Projects
None yet
Development

No branches or pull requests

3 participants