Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-6371

ObjectId.isValid returns true for non-objectid strings

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: bson-5.5.0
    • Component/s: None
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Use Case

      As a developer accepting a string OR object id as parameter
      I want ensure to convert the string to an ObjectId, if its a valid one
      So that I can pass the ObjectId to a mongodb query, or the plain string if its not a valid ObjectId

      Example: ObjectId.isValid('Land/Namibia') returns TRUE - which seems wrong.

      User Experience

      • ObjectId.isValid is reliable
      • If bug: What is the number of impacted customers? How severe is the impact? Is anyone blocked or broken?

      Dependencies

      • upstream and/or downstream requirements and timelines to bear in mind

      Risks/Unknowns

      • Previous use of ObjectId.isValid may break

      Acceptance Criteria

      Implementation Requirements

      • ObjectId.isValid only returns true for valid object ids

      Testing Requirements

      • ObjectId.isValid('Land/Namibia') returns false

      Documentation Requirements

      • DOCSP ticket, API docs, etc

      Follow Up Requirements

      • additional tickets to file, required releases, etc
      • if node behavior differs/will differ from other drivers, confirm with dbx devs what standard to aim for and what plan, if any, exists to reconcile the diverging behavior moving forward

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            extern.tim.gatzemeier@porsche.de Tim Gatzemeier
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: