Skip to content

[$30] Allow null in all the requests #137

@maxceem

Description

@maxceem

After implementing https://github.com/topcoder-platform/taas-apis/issues?q=is%3Aissue+is%3Aclosed one issue is revealed.

If I send null values to during POST/PUT/PATCH requests, such values would be rejected.

Example:

  1. Create a JOB using POSTMAN

    {
      "projectId": {{projectId}},
      "numPositions": 13,
      "skills": [
        "23e00d92-207a-4b5b-b3c9-4c5662644941",
        "7d076384-ccf6-4e43-a45d-1b24b1e624aa",
        "cbac57a3-7180-4316-8769-73af64893158",
        "a2b4bc11-c641-4a19-9eb7-33980378f82e"
      ],
      "title": "Dummy title - at most 64 characters"
    }     
  2. Copy the response of this operation and PUT the same response back to the API:

    {
     "projectId": 111,
     "numPositions": 13,
     "skills": [
         "23e00d92-207a-4b5b-b3c9-4c5662644941",
         "7d076384-ccf6-4e43-a45d-1b24b1e624aa",
         "cbac57a3-7180-4316-8769-73af64893158",
         "a2b4bc11-c641-4a19-9eb7-33980378f82e"
     ],
     "title": "Dummy title - at most 64 characters",
     "status": "sourcing",
     "id": "de51d5d7-dba9-4697-ba17-1cdbb6b22b2f",
     "createdAt": "2021-02-06T11:57:12.891Z",
     "createdBy": "57646ff9-1cd3-4d3c-88ba-eb09a395366c",
     "externalId": null,
     "description": null,
     "startDate": null,
     "endDate": null,
     "resourceType": null,
     "rateType": null,
     "workload": null,
     "updatedAt": null,
     "updatedBy": null,
     "deletedAt": null
    }      
  3. There would be a validation error:

    {
       "message": "\"data.externalId\" must be a string"
    }

DB allows null values for such fields. So for all the fields which allow null value in DB, we have to allow posting such values in Joi schemas for all models in all requests POST/PUT/PATCH.

Exception: don't allow "deletedAt": null as we don't allow setting it, we wouldn't return that field.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions