Skip to content

yacy.conf parser doesnt ignore comments, causes misleading error message #736

@sumodx

Description

@sumodx

The Docker container fails to start if the yacy.conf file contains a commented-out javastart_Xmx key in addition to an active one.

This fragile parsing leads to a cryptic Java error message (Error: Could not find or load main class...) that misdirects troubleshooting efforts away from the true root cause, which is a simple configuration file formatting issue.

Steps to Reproduce

  1. Create a docker-compose.yml file:

    version: '3.8'
    services:
      yacy:
        image: yacy/yacy_search_server:latest
        container_name: yacy-bug-test
        volumes:
          - ./yacy_data:/opt/yacy_search_server/DATA
          - ./yacy.conf:/opt/yacy_search_server/DATA/SETTINGS/yacy.conf
  2. Get the default configuration file:

    # Create a data directory to satisfy the volume mount
    mkdir ./yacy_data
    
    # Use a temporary container to extract the default yacy.conf
    docker run --rm --name yacy-tmp yacy/yacy_search_server:latest cat /opt/yacy_search_server/DATA/SETTINGS/yacy.conf > ./yacy.conf
  3. Modify the yacy.conf to trigger the bug:
    Edit the yacy.conf file. Find the line javastart_Xmx=Xmx600m. Comment it out and add a new, active line with a different value, like this:

    # javastart_Xmx=Xmx600m
    javastart_Xmx=Xmx2048m
  4. Attempt to start the container:

    docker-compose up

Expected Behavior

The container should start successfully. The startup script should parse the yacy.conf file, ignore any commented-out lines, and apply the single active javastart_Xmx=Xmx2048m setting.

Actual Behavior

The container immediately fails and enters a restart loop. The logs show the following misleading error, incorrectly identifying the memory value as a "main class":

Error: Could not find or load main class Xmx2048m
Caused by: java.lang.ClassNotFoundException: Xmx2048m

Analysis and Suggested Fix

The root cause appears to be a too simple parsing method, which likely finds all occurrences of the javastart_Xmx string without correctly filtering out commented lines. This results in a malformed java command being constructed.

A more robust parsing method would solve this. The script should be modified to ensure it ignores lines that begin with a # (or any non-alphanumeric character) before selecting the key-value pair.

For example, a grep command like grep '^javastart_Xmx' yacy.conf would be less likely to fail than one that finds the string anywhere on the line.

Thank you for your work on this project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions