Running ./bin/up on macOS can fail Mongo version validation even when MONGO_VERSION is valid.
Example error:
--------------------- ERROR -----------------------
Invalid MONGO_VERSION: MONGO_VERSION=6.0-jammy
MONGO_VERSION must start with the actual major version of mongo, followed by a dot.
Example: MONGO_IMAGE=my.dockerhub.com/custom-mongo
MONGO_VERSION=6.0-custom
--------------------- ERROR -----------------------
The error shows the parser returning MONGO_VERSION=... instead of just the value.
Environment
- OS: macOS
- Project: overleaf-toolkit
- Command:
./bin/up
- Config:
MONGO_IMAGE=mongo
MONGO_VERSION=6.0-jammy (also reproducible with 6.0)
Steps to Reproduce
- Set in
config/overleaf.rc:
MONGO_IMAGE=mongo
MONGO_VERSION=6.0-jammy
- Run:
- Observe validation error for
MONGO_VERSION.
Expected Behavior
MONGO_VERSION should be parsed as 6.0-jammy and pass validation in read_mongo_version().
Actual Behavior
MONGO_VERSION is parsed as MONGO_VERSION=6.0-jammy, causing this regex check to fail:
[[ ! "$mongo_version" =~ ^([0-9]+)\.(.+)$ ]]
Suspected Root Cause
In lib/shared-functions.sh, parsing helpers:
read_configuration()
read_variable()
are involved in extracting values from:
config/overleaf.rc
config/variables.env
When extraction returns the full assignment instead of value-only, downstream validation in read_mongo_version() fails.
Proposed Fix
Make read_configuration() and read_variable() robust and platform-independent by:
- Reading the first matching
KEY= line
- Stripping everything up to the first
=
- Removing optional surrounding matching quotes (
"..." or '...')
- Returning value-only output
This should ensure consistent behavior on macOS and Linux.
Optional Hardening
Add a defensive check in read_mongo_version() to detect accidental malformed values such as MONGO_VERSION=MONGO_VERSION=6.0-jammy and emit a more specific error message.
Affected File
If you want, I can also give you a shorter “minimal” version for maintainers who prefer compact issues.
Running
./bin/upon macOS can fail Mongo version validation even whenMONGO_VERSIONis valid.Example error:
The error shows the parser returning
MONGO_VERSION=...instead of just the value.Environment
./bin/upMONGO_IMAGE=mongoMONGO_VERSION=6.0-jammy(also reproducible with6.0)Steps to Reproduce
config/overleaf.rc:MONGO_IMAGE=mongoMONGO_VERSION=6.0-jammyMONGO_VERSION.Expected Behavior
MONGO_VERSIONshould be parsed as6.0-jammyand pass validation inread_mongo_version().Actual Behavior
MONGO_VERSIONis parsed asMONGO_VERSION=6.0-jammy, causing this regex check to fail:Suspected Root Cause
In
lib/shared-functions.sh, parsing helpers:read_configuration()read_variable()are involved in extracting values from:
config/overleaf.rcconfig/variables.envWhen extraction returns the full assignment instead of value-only, downstream validation in
read_mongo_version()fails.Proposed Fix
Make
read_configuration()andread_variable()robust and platform-independent by:KEY=line="..."or'...')This should ensure consistent behavior on macOS and Linux.
Optional Hardening
Add a defensive check in
read_mongo_version()to detect accidental malformed values such asMONGO_VERSION=MONGO_VERSION=6.0-jammyand emit a more specific error message.Affected File
lib/shared-functions.sh