Skip to main content
← Back to list
01Issue
BugOpenSwamp CLI
AssigneesNone

Relationships

#1302 datastore setup extension drops 'namespace' from --config, making extensions that require it impossible to configure

Opened by magistr · 7/20/2026

Summary

swamp datastore setup extension does not pass namespace from --config through to the extension. For any datastore extension that declares namespace as a required config field — e.g. @keeb/mongodb-datastore, where it forms the collection prefix t_<tenantId>_r_<namespace>_* — the command can therefore never succeed. It always fails Zod validation claiming the field is missing, even though it was supplied.

Core also does not inject its own datastore.namespace (from swamp datastore namespace set) into the extension config, so neither route supplies the value.

Reproduction

On a clean repo:

swamp repo init .
swamp extension trust add keeb
swamp extension pull @keeb/mongodb-datastore

swamp datastore setup extension @keeb/mongodb-datastore \
  --config '{"uri":"mongodb://HOST:27017/?replicaSet=rs0","username":"swamp","passwordEnv":"MONGO_PASSWORD","database":"swamp","namespace":"my-ns"}' \
  --hydration-strategy lazy

Result:

error: Invalid config for "@keeb/mongodb-datastore": [
  {
    "expected": "string",
    "code": "invalid_type",
    "path": [ "namespace" ],
    "message": "Invalid input: expected string, received undefined"
  }
]

namespace is present in --config and arrives as undefined.

Cases tested

All three fail identically, so the behaviour is independent of core's namespace state:

# swamp datastore namespace set run first? namespace in --config? Result
a yes yes Invalid config — namespace undefined
b no yes Invalid config — namespace undefined
c no no Invalid config — namespace undefined

Case (a) is the important one: core has a bound namespace and it is supplied in --config, and the extension still receives nothing.

Ruled out as causes:

  • stale bundle — reproduced after swamp extension pull --force (the runs also emit Using cached bundle for "mongodb/mod.ts" — source may have changed but bundle could not be regenerated, which is why this was checked)
  • shell quoting of the & in the Mongo URI — reproduced with the JSON supplied from a quoted heredoc inside a script file, no shell interpolation involved
  • stale binary — reproduced on 20260720.142822.0-sha.0caa5556 after swamp repo upgrade

Workaround

Hand-write the datastore block in .swamp.yaml. This is in fact what the extension's own README documents as the install path (setup is not mentioned):

datastore:
  type: "@keeb/mongodb-datastore"
  config:
    uri: "mongodb://HOST:27017/?replicaSet=rs0"
    username: "swamp"
    passwordEnv: "MONGO_PASSWORD"
    database: "swamp"
    namespace: "my-ns"

Configured this way the datastore loads and runs correctly, which confirms the extension reads config.namespace fine — only setup fails to deliver it.

Suggested fix

Forward unknown/extension-specific keys from --config verbatim to the extension's schema. If core is deliberately extracting namespace (because it also tracks datastore.namespace), it should re-inject it into the config it hands the extension rather than dropping it.

  • swamp-club#1265 — namespace workflow broken for extension datastores
  • swamp-club#1280 — sync guard skips the bound namespace directory on push

Note the interaction with those two: namespace set prints "Run swamp datastore namespace migrate --confirm", but per #1265 the local tier should never be namespaced for extension datastores, and per #1280 doing so makes a subsequent sync --push upload 0 files. So the advice printed by namespace set actively steers users into #1280.

Secondary observation

The extension README warns that swamp datastore setup OOMs on large existing trees ("core's migrator reads the tree into memory; at ~1 GB / ~100k files it dies"). The repo that prompted this report has ~15.5 GB / ~800k files, so even with namespace fixed the migrating path would not complete. A streaming migrator would make setup usable for repos of this size; today the only route is --skip-migration plus repopulation, which discards existing history.

Environment

  • swamp: 20260720.142822.0-sha.0caa5556
  • extension: @keeb/mongodb-datastore@2026.06.13.1
  • OS: linux (x86_64), Debian; bash 5.2.37
  • MongoDB 4.0+ replica set rs0, reachable and healthy

Note on this report's own submission

The first submission of this issue was corrupted by the issue-submission redactor: it matched the URI's auth-database query parameter and rewrote its value to [REDACTED-SECRET-1], in both the reproduction command and the workaround YAML. That query parameter names the authentication database, not a credential, so the redaction turned a correct repro into one that would not work if copied. The URI above now uses a placeholder to avoid the matcher. This looks like a recurrence of the class of problem in swamp-club#1241.

02Bog Flow
OPENTRIAGEDIN PROGRESSSHIPPED

Open

7/20/2026, 9:47:16 PM

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.