Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.18 regression: errors out with empty SERVER_FALLBACK_PAGE #218

Closed
OdyX opened this issue Jun 8, 2023 · 5 comments · Fixed by #219
Closed

2.18 regression: errors out with empty SERVER_FALLBACK_PAGE #218

OdyX opened this issue Jun 8, 2023 · 5 comments · Fixed by #219
Assignees
Labels
bug Something isn't working regression This is reproducible regression v2 v2 release

Comments

@OdyX
Copy link

OdyX commented Jun 8, 2023

Describe the bug
With the following Dockerfile, I could run the resulting image even with an empty SERVER_FALLBACK_PAGE:

ARG STATIC_WEB_SERVER_VERSION=2.17
FROM joseluisq/static-web-server:${STATIC_WEB_SERVER_VERSION}

# SWS configuration, check https://sws.joseluisq.net/configuration/environment-variables/
ENV SERVER_ROOT=/public

# Set fallback page for Single-page Applications
ARG SERVER_FALLBACK_PAGE
ENV SERVER_FALLBACK_PAGE=${SERVER_FALLBACK_PAGE}

# The whole website
COPY public/ /public/

Now, setting STATIC_WEB_SERVER_VERSION to 2.18, the same build gives:

error: a value is required for '--page-fallback <PAGE_FALLBACK>' but none was supplied

To Reproduce
Set an empty SERVER_FALLBACK_PAGE environment variable:

# Works
$ docker run -e SERVER_FALLBACK_PAGE= joseluisq/static-web-server:2.17
^C
# Fails
$ docker run -e SERVER_FALLBACK_PAGE= joseluisq/static-web-server:2.18
error: a value is required for '--page-fallback <PAGE_FALLBACK>' but none was supplied

For more information, try '--help'.

Environment and Specs

  • static-web-server: 2.18

This seems to be a regression caused by #215

@joseluisq
Copy link
Collaborator

Thanks for that!
We will fix that definitely, in fact, will be trivial to be fixed.
But for now, the "workaround" should be to unset the SERVER_FALLBACK_PAGE and avoid passing it to SWS if empty.

@joseluisq joseluisq added bug Something isn't working v2 v2 release labels Jun 8, 2023
@joseluisq joseluisq self-assigned this Jun 8, 2023
@joseluisq joseluisq added the regression This is reproducible regression label Jun 8, 2023
@OdyX
Copy link
Author

OdyX commented Jun 8, 2023

In fact, I've found that I can pass false to it too;

ARG STATIC_WEB_SERVER_VERSION=2.18
FROM joseluisq/static-web-server:${STATIC_WEB_SERVER_VERSION}

# SWS configuration, check https://sws.joseluisq.net/configuration/environment-variables/
ENV SERVER_ROOT=/public

# Set fallback page for Single-page Applications
ARG SERVER_FALLBACK_PAGE=false
ENV SERVER_FALLBACK_PAGE=${SERVER_FALLBACK_PAGE}

# The whole website
COPY public/ /public/

This is thanks to https://docs.rs/clap/latest/clap/struct.Arg.html#method.env:

Note that the value parser controls how flags are parsed. In this case we’ve selected FalseyValueParser. A false literal is n, no, f, false, off or 0. An absent environment variable will also be considered as false. Anything else will considered as true.

@joseluisq
Copy link
Collaborator

In fact, I've found that I can pass false to it too;

You can theoretically whatever string that Pathbuf supports. But it will get validated when trying to read the fallback page content at server start-up time.

This is thanks to https://docs.rs/clap/latest/clap/struct.Arg.html#method.env:

Note that the value parser controls how flags are parsed. In this case we’ve selected FalseyValueParser. A false literal is n, no, f, false, off or 0. An absent environment variable will also be considered as false. Anything else will considered as true.

Yeah, this is a rigid effect of our last migration to Clap v4.
Anyway, this is fixed now. See more details on PR #219.

@joseluisq
Copy link
Collaborator

You can use the devel Docker images to test the bugfix.

docker pull joseluisq/static-web-server:devel
docker pull joseluisq/static-web-server:devel-alpine

@joseluisq
Copy link
Collaborator

joseluisq commented Jun 16, 2023

Fixed on v2.19.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression This is reproducible regression v2 v2 release
Projects
None yet
2 participants