AutoKuma icon indicating copy to clipboard operation
AutoKuma copied to clipboard

Feature Request: improve error messages when parsing snippets

Open lgo opened this issue 1 year ago • 0 comments

I've sort of hit two problems.

  1. I was getting an error which doesn't have any logs for the snippet or context making it hard to pin down.
WARN [kuma_client::util] Error while parsing snippet arguments: expected value at line 1 column 27
  1. I had a snippet argument that wasn't valid JSON but was expected to be correct.
- 'kuma.__internal_web_app={ "port": 32400, "path": /web }'

Which had a mistake with /web not wrapped in quotes, so it's not valid JSON.

For posterity, this was my snippet

      AUTOKUMA__SNIPPETS__INTERNAL_WEB_APP: |-
        {% set args = args[0] %}
        {% if args.path %}
          {% set path = args.path %}
        {% else %}
          {% set path = '/' %}
        {% endif %}
        {{ container_name }}.group.name: {{ container_name }} App
        {{ container_name }}-http.http.name: {{ container_name }} Internal
        {{ container_name }}-http.http.parent_name: {{ container_name }}
        {{ container_name }}-http.http.url: http://{{ container_name }}:{{ args.port }}{{ path }}
        {% if args.status_code %}
          {{ container_name }}-http.http.status_code: {{ args.status_code }}
        {% endif %}
        {{ container_name }}-docker.docker.name: {{ container_name }} Docker
        {{ container_name }}-docker.docker.parent_name: {{ container_name }}
        {{ container_name }}-docker.docker.docker_container: {{ container_name }}
        {{ container_name }}-docker.docker.docker_host: 1
        {{ container_name }}-https.http.name: {{ container_name }} Web
        {{ container_name }}-https.http.parent_name: {{ container_name }}
        {{ container_name }}-https.http.url: https://{{ container_name }}.<x>.<y>{{ path }}
        {% if args.status_code %}
          {{ container_name }}-https.http.status_code: {{ args.status_code }}
        {% endif %}

btw, I absolutely love autokuma! It's helped me really shore up 50+ homelab containers while I migrated everything to a template with container-oriented definitions.

lgo avatar Jul 09 '24 17:07 lgo