Page MenuHomePhabricator

xLab: Add a validation rule to check whether a name/slug is already used by an existing instrument/experiment
Closed, ResolvedPublic8 Estimated Story Points

Description

Description

While working on T372952: (stretch) xLab: Add better validation to forms some pending work was considered as a follow up task. That's the case of a validation rule to check whether an existing instrument or experiment has already the same name or slug that the one the user is registering or updating.

One way to implement this would be using our own instrumentService.findInstrument function to check if there is already an instrument/experiment with the given name/slug but it seems we cannot use that service because it's using, indirectly, the fs node library (to load the config file where database configuration resides) which is not available in the browser where the frontend is executed while validating the form. That approach is causing problems when building xLab.

A workaround would be creating a util function to make a simple request to GET /instrument/slug but we don't have anything similar with the name. Is there any other valid approach?

We also have to determine is we want to check this only for the instrument/experiment name or also for the slug, because when we define the validation rules the slug for instruments/experiments was generated automatically but now it's filled by the user manually so I guess we should check same thing for that field

Acceptance Criteria

  • Determine when we need to check if an existing instrument or experiment has the same name or slug
  • xLab validates whether a name/slug are already used by an existing instrument/experiment when registering a new one
  • xLab validates whether a name/slug are already used by another existing instrument/experiment when updating an existing one

Details

Related Changes in Gerrit:
Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
Update validation and saving of instruments and experimentsrepos/data-engineering/test-kitchen!207cjmingfix-name-slug-spacesmain
Add validation for unique names and slugs.repos/data-engineering/test-kitchen!196cjmingT396151/validate-name-slugmain
Customize query in GitLab

Event Timeline

Milimetric triaged this task as Medium priority.Jun 12 2025, 3:30 PM
Milimetric set the point value for this task to 3.
Milimetric changed the point value for this task from 3 to 5.Jun 23 2025, 3:24 PM

Change #1163803 had a related patch set uploaded (by Clare Ming; author: Clare Ming):

[operations/deployment-charts@master] xLab: Deploy v0.7.4 release to staging

https://gerrit.wikimedia.org/r/1163803

Change #1163803 merged by jenkins-bot:

[operations/deployment-charts@master] xLab: Deploy v0.7.4 release to staging

https://gerrit.wikimedia.org/r/1163803

Milimetric updated Other Assignee, added: Sarai-WMF.
Milimetric added a subscriber: cjming.

Test status: QA FAIL

test scenario: Created an experiment with the name "test name", then created another experiment with the name "test name " ( this has a space at the end). It did not throw a validation and did not allow the user to create the experiment.

It displayed 409 conflict errors in the console log below

index-UXGpi3Vt.js:73 
            
            
           POST http://localhost/experiments 409 (Conflict)
(anonymous) @ index-UXGpi3Vt.js:73
xhr @ index-UXGpi3Vt.js:73
Qf @ index-UXGpi3Vt.js:75
_request @ index-UXGpi3Vt.js:76
request @ index-UXGpi3Vt.js:75
(anonymous) @ index-UXGpi3Vt.js:76
(anonymous) @ index-UXGpi3Vt.js:71
saveInstrument @ index-UXGpi3Vt.js:87
(anonymous) @ index-UXGpi3Vt.js:67
Lf.e.<computed> @ index-UXGpi3Vt.js:67
i @ index-UXGpi3Vt.js:90
Lt.n.<computed>.n.<computed> @ index-UXGpi3Vt.js:27
os @ index-UXGpi3Vt.js:18
dn @ index-UXGpi3Vt.js:18
n @ index-UXGpi3Vt.js:26Understand this error
index-UXGpi3Vt.js:17 [Vue warn]: Unhandled error during execution of native event handler 
  at <LaunchExperiment onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< Proxy(Object) {__v_skip: true} > > 
  at <RouterView key="/create-experiment" > 
  at <App>
index-UXGpi3Vt.js:87 Uncaught (in promise) TypeError: Spread syntax requires ...iterable[Symbol.iterator] to be a function
    at Ua.deserialize (index-UXGpi3Vt.js:87:31496)
    at Va.deserialize (index-UXGpi3Vt.js:87:33310)
    at Va.resume (index-UXGpi3Vt.js:87:33355)
    at Proxy.saveInstrument (index-UXGpi3Vt.js:87:38977)
    at async i (index-UXGpi3Vt.js:90:134968)

Sfaci updated Other Assignee, added: EChukwukere-WMF; removed: Sarai-WMF.

Change #1165181 had a related patch set uploaded (by Clare Ming; author: Clare Ming):

[operations/deployment-charts@master] xLab: Deploy v0.7.5 release to staging

https://gerrit.wikimedia.org/r/1165181

Change #1165181 merged by jenkins-bot:

[operations/deployment-charts@master] xLab: Deploy v0.7.5 release to staging

https://gerrit.wikimedia.org/r/1165181

Change #1165182 had a related patch set uploaded (by Clare Ming; author: Clare Ming):

[operations/deployment-charts@master] xLab: Deploy v0.7.5 release to production

https://gerrit.wikimedia.org/r/1165182

Change #1165182 merged by jenkins-bot:

[operations/deployment-charts@master] xLab: Deploy v0.7.5 release to production

https://gerrit.wikimedia.org/r/1165182

Sfaci updated Other Assignee, removed: EChukwukere-WMF.
Sfaci moved this task from Sign Off to Done on the Test Kitchen (Experiment Platform Sprint 8) board.
Sfaci added a subscriber: Sarai-WMF.
Milimetric changed the point value for this task from 5 to 8.Jul 2 2025, 3:11 PM