Skip to content

flock link stores a nameless site when the folder name cannot be a hostname, and the web server then fails to start #207

Todo

Description

@xiaozou-second

Platform

Linux

Flock version

1.1.1 (source build from main at 346231b)

OS version

Debian GNU/Linux 13 (trixie), x86_64

What happened?

flock link in a project folder whose name cannot become a hostname (for example ~/我的项目, Проект, or a folder named only with punctuation) exits 0, prints linked … → http://.test, and stores a site with an empty name.

The empty name makes the generated web configuration invalid: the domain becomes .test, and the Caddy adapter rejects https://.test with subject does not qualify for certificate: '.test'. While the daemon is already running this only appears as a flock status warning, but the next daemon start (reboot, flock restart, update) never starts the web server, so every site becomes unreachable — including sites that worked before. flock sites lists the broken entry as a row with an empty SITE and URL http://.test.

Expected: flock link rejects a name that cannot be a hostname, tells the user to pass one (flock link <name>), and stores nothing. Site names should be DNS labels, which the codebase already enforces for proxy names (hostLabel in internal/config/domains.go, checked by UpsertProxy), while Config.Upsert does not check the site name and config.SiteName returns "" when every character is replaced.

flock park has the same input path: parking a parent folder that contains a subfolder with an unusable name lists that subfolder as a nameless site too.

Recovery for an affected setup: cd <folder> && flock unlink, then restart the daemon (verified); or remove the nameless entry from config.json.

Steps to reproduce

Reproduced with a daemon built from main at 346231b, run with an isolated FLOCK_HOME and high ports (no system install; PHP is not installed, which is why the site row shows the PHP warning):

  1. Start the daemon with one working site (okapp.test). curl -H 'Host: okapp.test' http://127.0.0.1:18080/ returns HTTP 404 (the "no index/PHP" page), so the web server is up.
  2. mkdir -p /tmp/proj/我的项目 && cd /tmp/proj/我的项目 && flock link → exit 0, prints linked /tmp/proj/我的项目 → http://.test.
  3. flock sites → a row with an empty SITE and URL http://.test.
  4. flock status → warning web: adapt web config: subject does not qualify for certificate: '.test'.
  5. Stop and start the daemon again (as flock restart or a reboot does).
  6. curl -H 'Host: okapp.test' http://127.0.0.1:18080/ → HTTP 000 (nothing listens): the web server did not start.

The same folder linked with an explicit name still works (flock link my-project stores my-project.test), and an ASCII folder name links normally.

The Add Site endpoint used by the apps calls config.SiteName in internal/api/configapi.go and passes the result to the same Config.Upsert, so a site added from an app with an unusable name stores the same empty value.

Logs

$ flock link          # inside /tmp/proj/我的项目
linked /tmp/proj/我的项目 → http://.test

$ flock sites
SITE   PHP  URL                         ROOT                                 PATH
       8.5  project folder (detected, no index)                            /tmp/proj/我的项目
okapp  8.5  project folder (detected)                                      /tmp/proj/okapp

$ flock status        # after the daemon restart in step 5
daemon    running (pid 171775, v1.1.1, up 10s)
web       http :18080, https :18443
warning   web: adapt web config: subject does not qualify for certificate: '.test'

$ curl -H 'Host: okapp.test' http://127.0.0.1:18080/
000

After cd /tmp/proj/我的项目 && flock unlink and a daemon restart, okapp.test returns HTTP 404 again and the web-config warning is gone.

Activity

  1. xiaozou-second commented on Nov 25, 2026

    @xiaozou-second
    Author

    I can take this one.

    Proposed fix, following the validation the codebase already has for proxy names:

    • a site name must be a DNS label (hostLabel, the same rule UpsertProxy uses);
    • flock link exits non-zero with a clear message and tells you to pass a name (flock link <name>) instead of storing an empty site;
    • Config.Upsert rejects an invalid site name, so the Add Site endpoint cannot store one either;
    • parking skips a subfolder whose name produces no usable site name.

    Tests would cover Upsert, the parked-folder path in AllSites, and the flock link CLI path. I reproduced the current behaviour and verified the corrected behaviour locally on Linux.

    If you would rather keep deriving the name from the folder and generate a usable one instead of reporting an error, tell me and I will adjust. Otherwise I can open a PR once this issue is approved.

  2. onairmarc commented on Nov 25, 2026

    @onairmarc
    Member

    All yours @xiaozou-second

  3. onairmarc commented on Nov 25, 2026

    @onairmarc
    Member

    Try to keep the folder name where possible, but if there are edge cases, adjust as needed and we can reconvene at review.

  4. github-actions commented on Nov 25, 2026

    @github-actions

    Issue claimed by @xiaozou-second in PR #208.

  5. added
    claimed
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

claimedos: linux

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions