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

upgrade fails due invalid mongo version parsing #282

Open
qupfer opened this issue Aug 21, 2024 · 2 comments
Open

upgrade fails due invalid mongo version parsing #282

qupfer opened this issue Aug 21, 2024 · 2 comments

Comments

@qupfer
Copy link

qupfer commented Aug 21, 2024

Steps to Reproduce

  1. run ./bin/upgrade
  2. modify /config/overleaf.rc to new split mongo
MONGO_ENABLED=true
MONGO_DATA_PATH=data/mongo
MONGO_IMAGE=mongo
MONGO_VERSION=5.0
  1. run ./bin/upgrade

Expected Behaviour

  • should upgrade

Observed Behaviour

error message

---------------------  ERROR  -----------------------
  Invalid MONGO_VERSION: MONGO_VERSION=5.0

  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  -----------------------

Analysis

a set -x in lib/shared-functions.sh looks (for me) that some variable name/value splitting is not done correctly

overleaf:~/overleaf-toolkit# ./bin/upgrade 
Checking for code update...
No code update available for download
New docker image version available (5.1.1)
Current image version is '5.0.6' (from config/version)
Upgrade image? [y/n] y
Upgrading config/version from 5.0.6 to 5.1.1
++ read_configuration MONGO_IMAGE
++ local name=MONGO_IMAGE
++ grep -E '^MONGO_IMAGE=' /root/overleaf-toolkit/config/overleaf.rc
++ sed -r 's/^MONGO_IMAGE=(["'\'']?)(.+)\1$/\2/'
+ local mongo_image=MONGO_IMAGE=mongo
++ read_configuration MONGO_VERSION
++ local name=MONGO_VERSION
++ grep -E '^MONGO_VERSION=' /root/overleaf-toolkit/config/overleaf.rc
++ sed -r 's/^MONGO_VERSION=(["'\'']?)(.+)\1$/\2/'
+ local mongo_version=MONGO_VERSION=5.0
+ '[' -z MONGO_VERSION=5.0 ']'
+ [[ ! MONGO_VERSION=5.0 =~ ^([0-9]+)\.(.+)$ ]]
+ echo '---------------------  ERROR  -----------------------'
+ echo '  Invalid MONGO_VERSION: MONGO_VERSION=5.0'
+ echo ''
+ echo '  MONGO_VERSION must start with the actual major version of mongo, followed by a dot.'
+ echo '  Example: MONGO_IMAGE=my.dockerhub.com/custom-mongo'
+ echo '           MONGO_VERSION=6.0-custom'
+ echo '---------------------  ERROR  -----------------------'
+ exit 1

I think mongo_version should be 5.0 and not MONGO_VERSION=5.0

@dev-lukas
Copy link

This is indeed a bug that I can confirm.
Changing the lib/shared-functions.sh sed regex syntax in the read_variable() and read_configuration() from
"s/^$name=([\"']?)(.+)\1\$/\2/"
to
"s/^$name=['\"]?(.*)['\"]?$/\1/"
resolves this issue.

@OP-0
Copy link

OP-0 commented Nov 2, 2024

Seems that there is just a typo - escaped eol sign: \$ instead of $ . Capturing the character group works well, no need to drop it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants