You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Default container user can't create other users (readAnyDatabase/readWriteAnyDatabase grants fail) #752
Running the documentdb-local image with --username/--password, the user it creates can't actually create other users. If you try to add users in an init script with:
you get User is not authorized to perform this action.
I confirmed this is a bug, not expected behavior. Root cause: create_user's C implementation issues GRANT <role> TO <newuser> (and for readAnyDatabase, also GRANT pg_read_all_data TO <newuser>) as the invoking role rather than as a security-definer/superuser. Postgres requires ADMIN OPTION to grant a role to someone else — just being a member isn't enough — so the default user hits a permission wall.
I originally assumed GRANT documentdb_admin_role + ALTER ROLE ... CREATEROLE would fix it, but that's not enough by itself (tested against ghcr.io/documentdb/documentdb/documentdb-local:latest). The default user already has documentdb_admin_role membership, and just adding CREATEROLE still fails with:
ERROR: permission denied to grant role "documentdb_readonly_role"
DETAIL: Only roles with the ADMIN option on role "documentdb_readonly_role" may grant this role.
What actually works, run as the documentdb superuser:
GRANT documentdb_admin_role TO testuser WITH ADMIN OPTION;
GRANT documentdb_readonly_role TO testuser WITH ADMIN OPTION;
GRANT documentdb_readwrite_role TO testuser WITH ADMIN OPTION;
GRANT pg_read_all_data TO testuser WITH ADMIN OPTION;
GRANT pg_write_all_data TO testuser WITH ADMIN OPTION;
ALTER ROLE testuser CREATEROLE;
With all of that in place, createUser works both calling documentdb_api_v2.create_user directly and through the mongosh/gateway path, and the new user can log in afterward.
For a real fix, I'd rather not have to hand out ADMIN OPTION on pg_read_all_data/pg_write_all_data as a workaround — the container's default-user bootstrap (or create_user itself) should set this up out of the box, maybe by doing the grants as security-definer, so a user created with --username/--password can manage other users without any of this.
changed the title [-]Default container user (--username/--password) cannot create additional users without manual role grants[/-][+]Default container user (--username/--password) cannot create additional users — missing role grants[/+]on Oct 2, 2026
changed the title [-]Default container user (--username/--password) cannot create additional users — missing role grants[/-][+]Default container user can't create other users (readAnyDatabase/readWriteAnyDatabase grants fail)[/+]on Oct 2, 2026
Applied:write-operations, bug Project fields suggested: Component commands · Priority P1 · Effort M · Status Triage Confidence: 0.85 (llm)
Reasoning
LLM: The default container user cannot create other users due to missing ADMIN OPTION grants in create_user's C implementation, breaking a core user-management workflow for anyone using --username/--password in documentdb-local.
If a label is wrong, remove it manually and ping @patty-chow so the rules can be tuned. The bot will not re-label items that already have component labels.
Activity
[-]Default container user (--username/--password) cannot create additional users without manual role grants[/-][+]Default container user (--username/--password) cannot create additional users — missing role grants[/+][-]Default container user (--username/--password) cannot create additional users — missing role grants[/-][+]Default container user can't create other users (readAnyDatabase/readWriteAnyDatabase grants fail)[/+]documentdb-triage-tool commentedon Oct 2, 2026
🤖 Auto-triaged by documentdb-triage-tool.
Applied:
write-operations,bugProject fields suggested: Component
commands· PriorityP1· EffortM· StatusTriageConfidence: 0.85 (llm)
Reasoning
LLM: The default container user cannot create other users due to missing ADMIN OPTION grants in create_user's C implementation, breaking a core user-management workflow for anyone using --username/--password in documentdb-local.
If a label is wrong, remove it manually and ping
@patty-chowso the rules can be tuned. The bot will not re-label items that already have component labels.