Skip to content

macOS: MONGO_VERSION parsing fails in shared-functions.sh and reports valid values as invalid #426

@wavhudimulaudzi

Description

@wavhudimulaudzi

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

  1. Set in config/overleaf.rc:
    • MONGO_IMAGE=mongo
    • MONGO_VERSION=6.0-jammy
  2. Run:
    ./bin/up
  3. 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:

  1. Reading the first matching KEY= line
  2. Stripping everything up to the first =
  3. Removing optional surrounding matching quotes ("..." or '...')
  4. 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

  • lib/shared-functions.sh

If you want, I can also give you a shorter “minimal” version for maintainers who prefer compact issues.

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