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

Comments

3 participants
@kurtvm
Copy link

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Author

commented Jun 4, 2019

PR created commit f2a2d638cef2957d8486f1b8bb8d47e2e7bd231d

kurtvm added a commit to axinv/release that referenced this issue Jun 5, 2019

NicolasGeraud added a commit to gravitee-io/release that referenced this issue Jun 13, 2019

@NicolasGeraud

This comment has been minimized.

Copy link
Member

commented Jun 13, 2019

thanks @kurtvm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.