[GH-ISSUE #247] [Bug] Resource Sync not escaping backslashes on commit #2052

Closed
opened 2026-04-11 09:56:11 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @Copper9564 on GitHub (Jan 5, 2025).
Original GitHub issue: https://github.com/moghtech/komodo/issues/247

Hello!

After adding a stack containing a backslash in a service's command ('-allowGET=/v1\..{2}/(containers/.*|events|info)|/_ping') and committing to my git server, Komodo can no longer sync

ERROR: failed to read resources from "/repo-cache/<domain>/<repo>/main/latest/resources.toml"

TRACE:
	1: failed to parse resource file contents
	2: TOML parse error at line 67, column 25
   |
67 |       - '-allowGET=/v1\..{2}/(containers/.*|events|info)|/_ping'
   |                         ^
invalid escape sequence
expected `b`, `f`, `n`, `r`, `t`, `u`, `U`, `\`, `"`

Komodo isn't escaping the backslash before committing, then gets stuck trying to parse it back in since it's not escaped properly.

If I manually escape it on the git server then the issue goes away on Komodo's side.

Originally created by @Copper9564 on GitHub (Jan 5, 2025). Original GitHub issue: https://github.com/moghtech/komodo/issues/247 Hello! After adding a stack containing a backslash in a service's command (`'-allowGET=/v1\..{2}/(containers/.*|events|info)|/_ping'`) and committing to my git server, Komodo can no longer sync ``` ERROR: failed to read resources from "/repo-cache/<domain>/<repo>/main/latest/resources.toml" TRACE: 1: failed to parse resource file contents 2: TOML parse error at line 67, column 25 | 67 | - '-allowGET=/v1\..{2}/(containers/.*|events|info)|/_ping' | ^ invalid escape sequence expected `b`, `f`, `n`, `r`, `t`, `u`, `U`, `\`, `"` ``` Komodo isn't escaping the backslash before committing, then gets stuck trying to parse it back in since it's not escaped properly. If I manually escape it on the git server then the issue goes away on Komodo's side.
GiteaMirror added the bug label 2026-04-11 09:56:11 -05:00
Author
Owner

@mbecker20 commented on GitHub (Jan 6, 2025):

Can you clarify the difference in how you committed this change? Are you saying in the first case, you committed the change through the Komodo UI, while in the second, it was committed through manual editor (like VSCode) + command line commit?

<!-- gh-comment-id:2571825451 --> @mbecker20 commented on GitHub (Jan 6, 2025): Can you clarify the difference in how you committed this change? Are you saying in the first case, you committed the change through the Komodo UI, while in the second, it was committed through manual editor (like VSCode) + command line commit?
Author
Owner

@Copper9564 commented on GitHub (Jan 6, 2025):

I'm primarily using the resource sync one-way only from Komodo --> Gitea, but I think most people are defining resources from Git --> Komodo. So here's a clearer example to help replicate:

  1. Set up a resource sync with git (Gitea in my case). Set managed mode to enable commits from KomodoUI.

  2. Add this UI defined stack which contains a backslash via KomodoUI:

services:
  dockerproxy:
    image: wollomatic/socket-proxy:1
    command:
      - '-loglevel=info'
      - '-allowGET=/v1\..{2}/(containers/.*|events|info)|/_ping'            # <-- backslash
      - '-allowHEAD=/_ping'
      - '-watchdoginterval=300'
      - '-stoponwatchdog'
      - '-shutdowngracetime=10'
    restart: unless-stopped
    read_only: true
    mem_limit: 64M
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges
    user: 65534:999
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro

  1. Commit changes to git
    image

  2. Notice the commit action is successful, but now the resource sync status immediately says FAILED. Info tab shows the escape sequence error:
    image

  3. View the committed toml file (either directly on Gitea or with an editor like VSCode), and notice the backslash is unescaped which would prevent the toml from being parsed back into Komodo:

[[stack]]
name = "issue_247"
[stack.config]
server = "myserver"
file_contents = """
services:
  dockerproxy:
    image: wollomatic/socket-proxy:1
    command:
      - '-loglevel=info'
      - '-allowGET=/v1\..{2}/(containers/.*|events|info)|/_ping'    # <-- backslash
      - '-allowHEAD=/_ping'
      - '-watchdoginterval=300'
      - '-stoponwatchdog'
      - '-shutdowngracetime=10'
    restart: unless-stopped
    read_only: true
    mem_limit: 64M
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges
    user: 65534:999
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
"""
  1. Now if you add the 2nd backslash (directly on Gitea or other editor), then KomodoUI is able to parse after it refreshes from git.
    image

I'm not too familiar with TOML, but was also able to get it working by using the multi-line literal ''' instead of """, but then you lose the ability to actually escape things if needed. I'd guess the right way to address this is to scan for and escape backslashes when writing the TOML file(s) to be committed.

Hope that makes better sense. Thanks for your work on this project, and fantastic job thus far!

<!-- gh-comment-id:2573750752 --> @Copper9564 commented on GitHub (Jan 6, 2025): I'm primarily using the resource sync one-way only from Komodo --> Gitea, but I think most people are defining resources from Git --> Komodo. So here's a clearer example to help replicate: 1. Set up a resource sync with git (Gitea in my case). Set managed mode to enable commits from KomodoUI. 2. Add this UI defined stack which contains a backslash via KomodoUI: ``` yaml services: dockerproxy: image: wollomatic/socket-proxy:1 command: - '-loglevel=info' - '-allowGET=/v1\..{2}/(containers/.*|events|info)|/_ping' # <-- backslash - '-allowHEAD=/_ping' - '-watchdoginterval=300' - '-stoponwatchdog' - '-shutdowngracetime=10' restart: unless-stopped read_only: true mem_limit: 64M cap_drop: - ALL security_opt: - no-new-privileges user: 65534:999 volumes: - /var/run/docker.sock:/var/run/docker.sock:ro ``` 3. Commit changes to git ![image](https://github.com/user-attachments/assets/043ef4ef-d158-4311-95aa-9b11c02cd6e8) 4. Notice the commit action is successful, but now the resource sync status immediately says FAILED. Info tab shows the escape sequence error: ![image](https://github.com/user-attachments/assets/95de0120-d705-4624-811d-55f56ccfa6d5) 5. View the committed toml file (either directly on Gitea or with an editor like VSCode), and notice the backslash is unescaped which would prevent the toml from being parsed back into Komodo: ``` toml [[stack]] name = "issue_247" [stack.config] server = "myserver" file_contents = """ services: dockerproxy: image: wollomatic/socket-proxy:1 command: - '-loglevel=info' - '-allowGET=/v1\..{2}/(containers/.*|events|info)|/_ping' # <-- backslash - '-allowHEAD=/_ping' - '-watchdoginterval=300' - '-stoponwatchdog' - '-shutdowngracetime=10' restart: unless-stopped read_only: true mem_limit: 64M cap_drop: - ALL security_opt: - no-new-privileges user: 65534:999 volumes: - /var/run/docker.sock:/var/run/docker.sock:ro """ ``` 6. Now if you add the 2nd backslash (directly on Gitea or other editor), then KomodoUI is able to parse after it refreshes from git. ![image](https://github.com/user-attachments/assets/d06f5205-d566-4573-8ab6-f22f2b87e1be) I'm not too familiar with TOML, but was also able to get it working by using the multi-line literal `'''` instead of `"""`, but then you lose the ability to actually escape things if needed. I'd guess the right way to address this is to scan for and escape backslashes when writing the TOML file(s) to be committed. Hope that makes better sense. Thanks for your work on this project, and fantastic job thus far!
Author
Owner

@mbecker20 commented on GitHub (Jan 6, 2025):

Thanks so much for the detailed description, yes I can reproduce this and it is a tricky bug.

<!-- gh-comment-id:2573937421 --> @mbecker20 commented on GitHub (Jan 6, 2025): Thanks so much for the detailed description, yes I can reproduce this and it is a tricky bug.
Author
Owner

@june012006 commented on GitHub (Jan 27, 2025):

It also will not remove the escape backslashes syncing back to komodo. Which means we can't use resource sync for anything that requires toml special characters, such as the normal traefik host label (backticks)
Here is an example from my gitea stored toml, with only my domain stripped

[stack.config]
server = "server-s00xe"
file_contents = """
services:
  whoami:
    image: traefik/whoami
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.entrypoints=web"
      - "traefik.http.routers.whoami.rule=Host(/`whoami.mydomain.com/`)"
      - "traefik.http.middlewares.whoami-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.whoami.middlewares=whoami-https-redirect"
      - "traefik.http.routers.whoami-secure.entrypoints=websecure"
      - "traefik.http.routers.whoami-secure.rule=Host(/`whoami.mydomain.com/`)"
      - "traefik.http.routers.whoami-secure.tls=true"
      - "traefik.http.routers.whoami-secure.service=whoami"
      - "traefik.http.services.whoami.loadbalancer.server.port=80"
      - "traefik.docker.network=proxy"
    networks:
      - proxy
networks:
  proxy:
    external: true
"""

and the resulting compose file for the stack

services:
  whoami:
    image: traefik/whoami
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.entrypoints=web"
      - "traefik.http.routers.whoami.rule=Host(/`whoami.watermelononatoothpick.com/`)"
      - "traefik.http.middlewares.whoami-https-redirect.redirectscheme.scheme=https"
      - "traefik.http.routers.whoami.middlewares=whoami-https-redirect"
      - "traefik.http.routers.whoami-secure.entrypoints=websecure"
      - "traefik.http.routers.whoami-secure.rule=Host(/`whoami.watermelononatoothpick.com/`)"
      - "traefik.http.routers.whoami-secure.tls=true"
      - "traefik.http.routers.whoami-secure.service=whoami"
      - "traefik.http.services.whoami.loadbalancer.server.port=80"
      - "traefik.docker.network=proxy"
    networks:
      - proxy
networks:
  proxy:
    external: true

Fortunately, I only executed the sync on this one, which is only for troubleshooting

<!-- gh-comment-id:2616973464 --> @june012006 commented on GitHub (Jan 27, 2025): It also will not remove the escape backslashes syncing back to komodo. Which means we can't use resource sync for anything that requires toml special characters, such as the normal traefik host label (backticks) Here is an example from my gitea stored toml, with only my domain stripped ``` [stack.config] server = "server-s00xe" file_contents = """ services: whoami: image: traefik/whoami labels: - "traefik.enable=true" - "traefik.http.routers.whoami.entrypoints=web" - "traefik.http.routers.whoami.rule=Host(/`whoami.mydomain.com/`)" - "traefik.http.middlewares.whoami-https-redirect.redirectscheme.scheme=https" - "traefik.http.routers.whoami.middlewares=whoami-https-redirect" - "traefik.http.routers.whoami-secure.entrypoints=websecure" - "traefik.http.routers.whoami-secure.rule=Host(/`whoami.mydomain.com/`)" - "traefik.http.routers.whoami-secure.tls=true" - "traefik.http.routers.whoami-secure.service=whoami" - "traefik.http.services.whoami.loadbalancer.server.port=80" - "traefik.docker.network=proxy" networks: - proxy networks: proxy: external: true """ ``` and the resulting compose file for the stack ``` services: whoami: image: traefik/whoami labels: - "traefik.enable=true" - "traefik.http.routers.whoami.entrypoints=web" - "traefik.http.routers.whoami.rule=Host(/`whoami.watermelononatoothpick.com/`)" - "traefik.http.middlewares.whoami-https-redirect.redirectscheme.scheme=https" - "traefik.http.routers.whoami.middlewares=whoami-https-redirect" - "traefik.http.routers.whoami-secure.entrypoints=websecure" - "traefik.http.routers.whoami-secure.rule=Host(/`whoami.watermelononatoothpick.com/`)" - "traefik.http.routers.whoami-secure.tls=true" - "traefik.http.routers.whoami-secure.service=whoami" - "traefik.http.services.whoami.loadbalancer.server.port=80" - "traefik.docker.network=proxy" networks: - proxy networks: proxy: external: true ``` Fortunately, I only executed the sync on this one, which is only for troubleshooting
Author
Owner

@mbecker20 commented on GitHub (Aug 26, 2025):

There were changes here, is this still and issue?

<!-- gh-comment-id:3222771102 --> @mbecker20 commented on GitHub (Aug 26, 2025): There were changes here, is this still and issue?
Author
Owner

@Copper9564 commented on GitHub (Aug 26, 2025):

Ah, sorry 😅 - yes everything works as expected now. Thanks for all your work!

<!-- gh-comment-id:3225261486 --> @Copper9564 commented on GitHub (Aug 26, 2025): Ah, sorry 😅 - yes everything works as expected now. Thanks for all your work!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/komodo#2052