Skip to content

Hostnames with .system. in their name lead to "Invalid namespace" MongoDB errors

Summary

While trying to list data from a Bitbucket server, named gittest.system.local Congregate failed with the following error message:

pymongo.errors.OperationFailure: Invalid namespace: congregate.projects-gittest.system.local, full error: {'ok': 0.0, 'errmsg': 'Invalid namespace: congregate.projects-gittest.system.local', 'code': 2, 'codeName': 'BadValue'}

After some debugging, I realised that the code uses the src_hostname parameter from the configuration to generate a list of MongoDB collections.

According to the MongoDB documentation, the following Restriction on Collection Names apply:

Collection names should begin with an underscore or a letter character, and cannot:

  • ...
  • begin with the system. prefix. (Reserved for internal use.)
  • contain .system.

Steps to Reproduce

  1. Create a source system with an FQDN containing .system. in its name (e.g. git.system.local)
  2. Configure Congregate with src_hostname = https://git.system.local
  3. Run congregate list

Log traces

Rotating and emptying '/opt/congregate/data/logs/congregate.log'
[10 Sep 2025 13:30:19][INFO]|list_source.list_data:437| Listing data from bitbucket server source type - https://gittest.system.local
Traceback (most recent call last):
  File "/opt/congregate/congregate/main.py", line 739, in <module>
    main()
  File "/opt/congregate/congregate/main.py", line 382, in main
    list_client.list_data()
  File "/opt/congregate/congregate/cli/list_source.py", line 443, in list_data
    self.list_bitbucket_data()
  File "/opt/congregate/congregate/cli/list_source.py", line 149, in list_bitbucket_data
    mongo, p, g, u = self.mongo_init(subset=self.subset)
  File "/opt/congregate/congregate/cli/list_source.py", line 475, in mongo_init
    mongo = CongregateMongoConnector()
  File "/opt/congregate/congregate/helpers/congregate_mdbc.py", line 17, in __init__
    self.__setup_db()
  File "/opt/congregate/congregate/helpers/congregate_mdbc.py", line 59, in __setup_db
    self.create_unique_index(collection, "id")
  File "/opt/congregate/congregate/helpers/mdbc.py", line 39, in create_unique_index
    return self.db[collection].create_index(key, unique=True)
  File "/home/ps-user/.cache/pypoetry/virtualenvs/congregate-j_w_A-A3-py3.10/lib/python3.10/site-packages/pymongo/collection.py", line 2271, in create_index
    return self.__create_indexes([index], session, **cmd_options)[0]
  File "/home/ps-user/.cache/pypoetry/virtualenvs/congregate-j_w_A-A3-py3.10/lib/python3.10/site-packages/pymongo/collection.py", line 2158, in __create_indexes
    self._command(
  File "/home/ps-user/.cache/pypoetry/virtualenvs/congregate-j_w_A-A3-py3.10/lib/python3.10/site-packages/pymongo/collection.py", line 250, in _command
    return sock_info.command(
  File "/home/ps-user/.cache/pypoetry/virtualenvs/congregate-j_w_A-A3-py3.10/lib/python3.10/site-packages/pymongo/pool.py", line 740, in command
    return command(
  File "/home/ps-user/.cache/pypoetry/virtualenvs/congregate-j_w_A-A3-py3.10/lib/python3.10/site-packages/pymongo/network.py", line 177, in command
    helpers._check_command_response(
  File "/home/ps-user/.cache/pypoetry/virtualenvs/congregate-j_w_A-A3-py3.10/lib/python3.10/site-packages/pymongo/helpers.py", line 180, in _check_command_response
    raise OperationFailure(errmsg, code, response, max_wire_version)
pymongo.errors.OperationFailure: Invalid namespace: congregate.projects-gittest.system.local, full error: {'ok': 0.0, 'errmsg': 'Invalid namespace: congregate.projects-gittest.system.local', 'code': 2, 'codeName': 'BadValue'}
Edited by Christian Affolter