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

[repository] [mongodb] Upgrade script 1.25 fails when application.metadata field does not exist #2331

Closed
kurtvm opened this issue Jun 3, 2019 · 3 comments · Fixed by gravitee-io/release#96

Comments

@kurtvm
Copy link

kurtvm commented Jun 3, 2019

When upgrade to version 1.25 (or through 1.25 to 1.26), one needs to run mongodb upgrade
scripts as explained by https://github.com/gravitee-io/release/tree/master/upgrades/1.25.0

However, the first script fails if the collection application does not have the metadata field
https://raw.githubusercontent.com/gravitee-io/release/master/upgrades/1.25.0/mongodb/1-applications-migration.js

Expected Behavior

If the metadata field does not exist in collection application - then create the field metadata.type=application.type

Current Behavior

Upgrade script fails with
TypeError: application.metadata is undefined

Possible Solution

The expression in the if statement
if (application.type && !application.metadata && !application.metadata.type)
might be rewritten to
if (application.type && !("metadata" in application))

Steps to Reproduce (for bugs)

  1. install version 1.24 using mongodb db store
  2. upgrade software to version 1.25
  3. run mongodb upgrade scripts

Context

Failing to run mongodb upgrade scripts results in http-400 on a HTTP PUT /management/apis/ and visual error 'must not be null' in ui when modifying policies

Your Environment

  • Version used: 1.25 & 1.26
@brasseld
Copy link
Member

brasseld commented Jun 4, 2019

Hi @kurtvm

Do you think you can provide a PR to fix the script ?

Thanks.

@brasseld brasseld changed the title Mongodb upgrade script 1.25 fails when application.metadata field does not exist [repository] [mongodb] Upgrade script 1.25 fails when application.metadata field does not exist Jun 4, 2019
@brasseld brasseld added this to the APIM - 1.25.6 milestone Jun 4, 2019
@kurtvm
Copy link
Author

kurtvm commented Jun 4, 2019

PR created commit f2a2d638cef2957d8486f1b8bb8d47e2e7bd231d

kurtvm added a commit to axinv/release that referenced this issue Jun 5, 2019
NicolasGeraud pushed a commit to gravitee-io/release that referenced this issue Jun 13, 2019
@NicolasGeraud
Copy link
Member

thanks @kurtvm

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

Successfully merging a pull request may close this issue.

3 participants