Tab completion fails on rs.initiate() with 'NotPrimaryOrSecondary' error in mongosh

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Autocomplete
    • None
    • None
    • Developer Tools

      Issue Summary

      When starting a custom mongod as a single-node replica set for testing, tab completion on rs.initiate in mongosh now results in an error: MongoServerError: node is not in primary or recovering state. This behavior is a regression, as previously tab completion worked as expected before running rs.initiate().

      Context

      • Custom mongod started as single-node replica set (for features like change streams)
      • Fresh server directory requires rs.initiate() before cluster operations
      • Previously, workflow was: rs.init → Tab → rs.initiate() → Enter
      • Now, tab completion triggers the following error:
        MongoServerError: node is not in primary or recovering state
            at Connection.sendCommand (...)
            ...
            errmsg: 'node is not in primary or recovering state',
            code: 13436,
            codeName: 'NotPrimaryOrSecondary'
        
      • Anna Henningsen confirmed this is a mongosh bug and should be tracked with a MONGOSH ticket

      Proposed Solution

      • Investigate and fix tab completion logic in mongosh for rs.initiate so it does not trigger server commands that require primary or recovering state before initialization
      • Ensure tab completion works for rs.initiate on a freshly started single-node replica set

      Original Slack thread
      This ticket was generated by AI from a Slack thread.

            Assignee:
            Unassigned
            Reporter:
            Ivan Fefer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: