Skip to content

bug: repo directory names with spaces or special chars produce invalid Docker container names #74

@egouilliard-leyton

Description

@egouilliard-leyton

Context

Discovered during implementation of fix for container name collision (#18).

Description

The container name is built as cognitx-codegraph-{repo_name}-{hash} where repo_name = detected.root.name (the bare directory name). Docker container names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*. A git root with a space in its name (e.g. my project) would produce cognitx-codegraph-my project-abcd1234, which Docker will reject.

Reproducer:

mkdir "my project" && cd "my project" && git init && codegraph init --yes --skip-docker --skip-index
# docker-compose.yml is written with an invalid container_name
docker compose up -d  # fails: invalid container name

Suggested approach

Sanitize repo_name before interpolating it into the container name — replace any character outside [a-zA-Z0-9_.-] with - (and collapse repeated dashes).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions