js-bson - PR #911: fix: count empty-scope Code as code_with_scope in calculateObjectSize

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • 2
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Expected Behavior

      As a... developer
      I expect... alignment between the predicted/precalculated size of a BSON object and the size of a BSON object after it is written
      When... invoked through the parallel `calculate_size.ts` and `serializer.ts` paths

      Actual Behavior and Impact

      • What is the actual behavior?
        • In the specific case of `code_with_scope`, serializer.ts and the calculate_size.ts have subtly different conditionals before emitting code_with_scope:
          • serializer.ts: codeValue.scope && typeof codeValue.scope === 'object'
          • calculate_size.ts: value.scope != null && Object.keys(value.scope).length > 0
      • If bug: What is the number of impacted customers? How severe is the impact? Is anyone blocked or broken?
        • Low severity. Serialization does not rely on the calculation of calculate_size.ts and creates its own buffer

      Dependencies

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

      Risks/Unknowns

      • What could go wrong while implementing this change? (e.g., performance, inadvertent behavioral changes in adjacent functionality, existing tech debt, etc)
        • none
      • Is there an opportunity for better cross-driver alignment or testing in this area?
        • no
      • Is there an opportunity to improve existing documentation on this subject?
        • no

      Acceptance Criteria

      Implementation Requirements

      • open question: Do we want to serialize empty scopes? Do they do anything? Are they functionally different from null scopes? It would seem there are no values in empty scopes to bind to the Code. Stated more narrowly: do we want to update the matching condition in the reverse direction?
        • Option A (the PR) set calculate_size.ts to match serializer.ts
          • serializer.ts: codeValue.scope && typeof codeValue.scope === 'object'
          • calculate_size.ts: value.scope != null && Object.keys(value.scope).length > 0 to codeValue.scope && typeof codeValue.scope === 'object'
        • Option B set serializer.ts to match calculate_size.ts
          • serializer.ts: codeValue.scope && typeof codeValue.scope === 'object' to value.scope != null && Object.keys(value.scope).length > 0
          • calculate_size.ts: value.scope != null && Object.keys(value.scope).length > 0

      Testing Requirements

      • one or more unit tests covering:
        • a `Code` with no scope
        • a `Code` with a scope with no keys
        • a `Code` with a scope with keys

      Documentation Requirements

      • none

      Follow Up Requirements

      • none

            Assignee:
            Unassigned
            Reporter:
            TPM Jira Automations Bot
            None
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: