mongostat calls url.Parse on connection strings, which fails with unix domain socket connection string

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

      In mongostat.go, there is a rewriteURI function that attempts to call url.Parse on the connection string passed on the CLI. But MongoDB connection strings are not all valid URLs, so this can fail, like we see in this example. This code needs to be rewritten to work with connection strings and not treat them as URIs.


      Problem Statement/Rationale

      mongostat does not support unix domain sockets like other mongodb database tools.  mongostat should support unix domain sockets for connection uri

      Steps to Reproduce

       

      mongostat --version
      mongostat version: 100.17.0
      git version: 0b142f65e139525881b6a343bc56d8d98e5a1f90
      Go version: go1.25.9
         os: linux
         arch: amd64
         compiler: gc
      
      mongostat --uri "mongodb://%2Ftmp%2Fmongodb-27019.sock" -n 1
      2026-05-25T02:05:57.282+0000    parse "mongodb://%2Ftmp%2Fmongodb-27019.sock": invalid URL escape "%2F"
      

       

      Expected Results

      Expect mongostat to connect and output statistics. mongotop for example:

      mongotop --uri "mongodb://%2Ftmp%2Fmongodb-27019.sock"  -n1
      2026-05-25T02:04:46.710+0000    connected to: mongodb://%2Ftmp%2Fmongodb-27019.sock                    ns    total    read    write    2026-05-25T02:04:47Z
        admin.system.version      0ms     0ms      0ms                        
      config.system.sessions      0ms     0ms      0ms                        
         config.transactions      0ms     0ms      0ms                        
        local.system.replset      0ms     0ms      0ms                     

      Actual Results

       

      mongostat --uri "mongodb://%2Ftmp%2Fmongodb-27019.sock" -n 1
      2026-05-25T02:05:57.282+0000    parse "mongodb://%2Ftmp%2Fmongodb-27019.sock": invalid URL escape "%2F"
      

       

      Additional Notes

      Any additional information that may be useful to include.

            Assignee:
            Unassigned
            Reporter:
            Christopher Dellaway
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: