Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-32663

Make it an error to reference a nonexistent error code via JavaScript

    • Fully Compatible
    • TIG 2018-03-12

      In the shell, referencing non-existent error codes on the generated ErrorCodes object gives undefined but should throw an error.

      During SERVER-31335 it was discovered that a test was calling

      assert.writeErrorWithCode(res, ErrorCodes.DocumentFailedValidation)
      

      (link to code). This was a typo, and ErrorCodes.DocumentFailedValidation is undefined. At the time, the assert function assumed a falsey error code meant that any code was okay, so this assertion passed. assert.writeErrorWithCode no longer allows undefined as an error code. But we should still throw if a non-existent error code is referenced.

      Per Max's suggestion

      I think we'd need to have the Python script generate the ErrorCodes object as a Proxy object and make it error (or abort) if any property is accessed that isn't defined on the ErrorCodes object itself.

            Assignee:
            david.bradford@mongodb.com David Bradford (Inactive)
            Reporter:
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: