9001 / 9001/copyparty

--idp-gsep can't be just space

Open Beginner friendly
#1,020 2 comments 0 reactions 1 assignee Claimed by @9001 View on GitHub
bug
Dominant language
Python
Stars
46.7k
Forks
1.9k
Avg merge
9d 2h
Merged PRs (30d)
4

Description

### Describe the bug
if I use `--idp-gsep " "` I get a python error:

```
File "/nix/store/nniir0jrvgw1xv71gl3lsq3xbsfb79wz-copyparty-1.19.20/lib/python3.12/site-packages/copyparty/svchub.py", line 1156, in _process_config
setattr(self.args, k, re.compile("[%s]" % (ptn,)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^
...

File "/nix/store/vxl8pzgkkw8vdb4agzwm58imrfclmfrx-python3-3.12.11/lib/python3.12/re/_parser.py", line 568, in _parse
raise source.error("unterminated character set",
re.error: unterminated character set at position 0
```

I think the gsep string is stripped, becomes "", and then that results in the regex compile error above.

### To Reproduce
I'm using caddy + caddy-security, which allows directives to add roles:
```caddyfile
transform user {
exact match origin google
exact match email me@gmail.com
action add role authp/user
action add role authp/copyparty-user
}
```

These roles are passed to copyfile in a header like:
`x-token-user-roles: authp/user authp/copyparty-user`

The default `--idp-gsep` will parse these as one group, since the space is not a default separator

### Expected behavior
I should be able to specify `--idp-gsep " "` and have space be the only separator in the list of idp groups

### Server details (if you're NOT using docker/podman)
remove the ones that are not relevant:
* **server OS / version:** NixOS 25.05
* **what copyparty did you grab:** (sfx/exe/pip/arch/...) built-in version
* **how you're running it:** (in a terminal, as a systemd-service, ...) nix pkg
* run copyparty with `--version` and grab the last 3 lines (they start with `copyparty`, `CPython`, `sqlite`) and paste them below this line:
```
copyparty v1.19.20 "usernames" (2025-11-02)
CPython v3.12.11 on Linux64 6.8.12 [GCC 14.3.0]
sqlite 3.48.0*1 | jinja 3.1.6 | pyftpd 2.0.1 | tftp (None)
```
* **copyparty arguments and/or config-file:**
```nix
services.copyparty = {
enable = true;

settings = {
#######################################
# misc
unlist = [
"^@eaDir"
".stfolder"
];
name = "";

#######################################
# network
# listening interface. note: exposing the copyparty service through any
# other interface, including LAN or Tailscale, opens up the possibility
# for things like spoofing the X-Forwarded-For header.
i = "127.0.0.1";

#######################################
# idp/user
auth-ord = "idp"; # no other access method
no-bauth = true; # disable basic authentication
idp-h-usr = "x-token-user-email";
idp-h-grp = "x-token-user-roles";
idp-gsep = " ";
idp-logout = "";

#######################################
# proxy
rproxy = 1;
xff-src = "127.0.0.1/32"; # only allow localhost reverse proxy
# trust the x-forwarded-for header from caddy:
xff-hdr = "X-Forwarded-For";

#######################################
# troubleshooting
# convenient debug option:
# log all incoming request headers from the proxy
ihead = "*";

#######################################
# ui
ui-nosrvi = true; # hide server-info in the UI
# ui-noacci = true; # hide account-info in the UI
# ui-nocpla = true; # hide cpanel-link in the UI
# ui-nolbar = true; # hide link-bar in the UI
# ui-nombar = true; # hide top-menu in the UI
# ui-nonav = true; # hide navpane+breadcrumbs in the UI
# ui-notree = true; # hide navpane in the UI
# ui-norepl = true; # hide repl-button in the UI
# ui-noctxb = true; # hide context-buttons in the UI

#######################################
# files
e2dsa = true; # enables general file indexing
e2ts = true; # enables audio metadata indexing
hist = "";
};
};
```

### Workaround
I can work around the problem by defeating the strip with : `--idp ", ,"` which will use commas or spaces as the separator. 🤷🏽‍♀️

Contributor guide

Open the contributing guide

Research direction

Look at svchub.py line 1156 where the idp-gsep pattern is compiled into a regex. The bug is that stripping the separator string results in an empty regex character set. Check how the argument is parsed and stripped, then adjust the logic to preserve a single space. Test by running copyparty with --idp-gsep " " and verifying that space-separated roles in the x-token-user-roles header are correctly split.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
authentication, backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.