CarnegieLearningWeb / UpGrade

Framework for adding A/B testing to education applications
https://www.upgradeplatform.org/
BSD 3-Clause "New" or "Revised" License
26 stars 13 forks source link

Validation errors to `/experiments` endpoint #1002

Closed danoswaltCL closed 1 year ago

danoswaltCL commented 1 year ago

Version where bug was found: e.g "5.0.2"

Describe the bug When trying to add a valid factorial experiment, I get a 400 validation error. This has been seen on POST and PUT

2023-09-08 16:57:01   endpoint: '/api/experiments',
2023-09-08 16:57:01   request_method_type: 'POST',
2023-09-08 16:57:01   level: 'error',
2023-09-08 16:57:01   message: ExperimentError {
2023-09-08 16:57:01     name: 'BadRequestError',
2023-09-08 16:57:01     message: "Invalid body, check 'errors' property for more info.",
2023-09-08 16:57:01     endPoint: '/api/experiments',
2023-09-08 16:57:01     errorCode: 400,
2023-09-08 16:57:01     type: 'Parameter not in the correct format'
2023-09-08 16:57:01   },
2023-09-08 16:57:01   timestamp: '2023-09-08T20:57:01.268Z'

To Reproduce Create a factorial experiment in stepper, on submit it seems to always error, not sure if there is one field that is causing it.

Example request that produced the error:

{"name":"ASDF","description":"","consistencyRule":"individual","assignmentUnit":"individual","type":"Factorial","context":["assign-prog"],"tags":[],"logging":false,"conditions":[{"id":"99c66529-dbef-4a11-a69c-b53901275bbb","name":"ASDF=FDF; ASDFFDF=ASDFDFFFF","conditionCode":"ASDF=FDF; ASDFFDF=ASDFDFFFF","assignmentWeight":25,"order":1,"levelCombinationElements":[{"id":"ede50759-76b5-46fb-8610-d47b5e1a5a7a","level":{"id":"921bbe47-feb6-49f0-a710-fc877ad167e3","name":"FDF","payload":""}},{"id":"c1ff0e01-cd65-462e-ae33-cd29d004083a","level":{"id":"c77fb67f-6ab7-4da5-9de4-3fd9d6adcc2a","name":"ASDFDFFFF","payload":""}}]},{"id":"c7960895-fe88-4eb7-bf7b-e358cfec9cbb","name":"ASDF=FDF; ASDFFDF=AFAFAFAFAF","conditionCode":"ASDF=FDF; ASDFFDF=AFAFAFAFAF","assignmentWeight":25,"order":2,"levelCombinationElements":[{"id":"1a1ca95b-f17c-406c-bd2f-e73212d83e3e","level":{"id":"921bbe47-feb6-49f0-a710-fc877ad167e3","name":"FDF","payload":""}},{"id":"0082fbbd-28eb-42da-876d-aa273610ba2a","level":{"id":"804a1885-a3fa-4f69-b364-0e00b32872bb","name":"AFAFAFAFAF","payload":""}}]},{"id":"c29751f2-46ec-4cf7-9b32-51539a5cee28","name":"ASDF=ASFA; ASDFFDF=ASDFDFFFF","conditionCode":"ASDF=ASFA; ASDFFDF=ASDFDFFFF","assignmentWeight":25,"order":3,"levelCombinationElements":[{"id":"97f56691-9427-4668-ad58-ae7c308eeb46","level":{"id":"719130ff-8a06-4743-ae82-ce19f340931b","name":"ASFA","payload":""}},{"id":"d2d88c83-56f4-458f-b3db-eae4107602da","level":{"id":"c77fb67f-6ab7-4da5-9de4-3fd9d6adcc2a","name":"ASDFDFFFF","payload":""}}]},{"id":"e1f9af82-de76-4e47-9c18-d736e73d807a","name":"ASDF=ASFA; ASDFFDF=AFAFAFAFAF","conditionCode":"ASDF=ASFA; ASDFFDF=AFAFAFAFAF","assignmentWeight":25,"order":4,"levelCombinationElements":[{"id":"7db1265e-4ce7-428d-a9fe-404e694bb8f8","level":{"id":"719130ff-8a06-4743-ae82-ce19f340931b","name":"ASFA","payload":""}},{"id":"062c5033-1390-4dcf-ba18-d336abf257f3","level":{"id":"804a1885-a3fa-4f69-b364-0e00b32872bb","name":"AFAFAFAFAF","payload":""}}]}],"partitions":[{"id":"2c3e0f1b-b967-46c9-92f9-c504b9877459","site":"SelectSection","target":"absolute_value_plot_equality","description":"","order":1,"excludeIfReached":false}],"factors":[{"name":"ASDF","description":"","order":1,"levels":[{"id":"921bbe47-feb6-49f0-a710-fc877ad167e3","name":"FDF","payload":{"type":"string","value":""}},{"id":"719130ff-8a06-4743-ae82-ce19f340931b","name":"ASFA","payload":{"type":"string","value":""}}]},{"name":"ASDFFDF","description":"","order":2,"levels":[{"id":"c77fb67f-6ab7-4da5-9de4-3fd9d6adcc2a","name":"ASDFDFFFF","payload":{"type":"string","value":""}},{"id":"804a1885-a3fa-4f69-b364-0e00b32872bb","name":"AFAFAFAFAF","payload":{"type":"string","value":""}}]}],"conditionPayloads":[],"experimentSegmentInclusion":{"segment":{"individualForSegment":[],"groupForSegment":[],"subSegments":[],"type":"private"}},"experimentSegmentExclusion":{"segment":{"individualForSegment":[],"groupForSegment":[],"subSegments":[],"type":"private"}},"filterMode":"excludeAll","queries":[],"eShow more
RidhamShah commented 1 year ago

@danoswaltCL Some part of the example experiment is cut off. Can you send the whole experiment?

Yagnik56 commented 1 year ago

Issue was that payload for levelelements in condition was expected as {type: payload type, value: string} but it was sending it as string, we were converting payload from string to {type: payload type, value: string} when we go next or save the data but because conditionTable was updating live on every change we perform in factorTable it was reading it directly from form as string. I have changed format in form only to {type: payload type, value: string} format so this issue is resolved.

danoswaltCL commented 1 year ago

tested in staging and passed