Change:
the Nix configured list of IDs */ + lib.optionalString s.override '' <del> old_conf_${conf_type}_ids="$(curl -X GET ${s.baseAddress} | ${jq} --raw-output '.[].${s.GET_IdAttrName}')" for id in ''${old_conf_${conf_type}_ids}; do if echo ${lib.concatStringsSep " " s.new_conf_IDs} | grep -q $id; then continue else curl -X DELETE ${s.baseAddress}/$id fi </del> <ins> stale_${conf_type}_ids="$(curl -X GET ${s.baseAddress} | ${jq}  --argjson new_ids ${lib.escapeShellArg (builtins.toJSON s.new_conf_IDs)}  --raw-output  '[.[].${s.GET_IdAttrName}] - $new_ids | .[]' )" for id in ''${stale_${conf_type}_ids}; do curl -X DELETE ${s.baseAddress}/$id </ins> done '' ))

Discussion:
if a folder is a substring of another folder, we don't delete it even if we have overrideFolders and the substring id got removed from the config. Steps to reproduce the behavior: a folder with id "xxx" a folder with id "yyyzzzxxx"; folder with id "xxx" from config never gets removed folder "xxx" should have been removed after removing it from config <!-- Please @ people who are in the list of the offending package or module. If in doubt, check for whoever last touched something. --Please run and paste the result.
Thanks for spotting the issue and reporting :) It sounds to me like a issue not being accurate... Maybe only the 1st commit in does the job?
yes, the first commit solves the issue with substring ids. the second commit solves the issue with ids like "hello/world". I tried escaping the id to send a DELETE request but couldn't find out how to correctly escape the / in the id
I'd never imagine someone would do that LOL. What if we'd impose a check in the module that would prevent such ids? Is it even supported upstream?
well it works in the webinterface. so it seems supported? also the default value for the id in our nixos module is the key, which also is the path. I usually do something like so all those ids are broken. as a workaround we could replace all / in the id, but that would break interaction with non nixos setups. PUTing the config seems to not have that issue. Were there any problems with PUTing the config if we want to override folders and devices anyway?
Could you perhaps give more context? I don't understand what kind of a json object is passed to the commands when you do that. I also observed in the below code that "/" are taken care of in a special way? As I in , I don't like how the code diverges in the , and it seems to me it doesn't handle the case where you want to delete a stale folder, and you don't .
yeah the PR sadly isn't complete, I just used it as a test for my local systems where I just override everything. I guess we need to handle individual overrides better, but not sure how. setting wold result in a nixos configuration of when I initially wrote this module this seemed unique enough and like a sane default.

I thought about hashing the key for the id, but this would have ended in unnecessary long keys.
I see. I think that using such IDs for folders and devices is very uniqe usage... I tend towards suggesting to take the 1st commit of the PR, and a message when evaluating the script, in case the folders' IDs contain "/", and is true. However, that would not solve your particular, usage. Perhaps we can talk with upstream about it? They are rather responsive from my experience.
that sounds like an idea. I'm busy the next couple of days, but you can cherry pick the first commit from my PR and close it and we will continue with this once we have some better idea how to handle things and we maybe have an answer from upstream?