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

Cannot use dot in keys when using Object format #250

Open
jonaskello opened this issue May 9, 2018 · 5 comments · Fixed by A-312/node-blueconfig#1
Open

Cannot use dot in keys when using Object format #250

jonaskello opened this issue May 9, 2018 · 5 comments · Fixed by A-312/node-blueconfig#1

Comments

@jonaskello
Copy link

I have a case where an URL is a key in an object that is a default value for a setting. Something like this:

export const conf = convict({
  npmrc: {
    doc: "Config for installing plugin packages.",
    format: "Object",
    default: {
      registries: {
        "@foo": "https://npm.foo.com/",
      },
      authTokens: {
        "https://npm.foo.com/": {
          type: "Bearer",
          token: "XXXX",
        },
      },
    },
  }
}

This fails to validate with this error:

Error: cannot find configuration param 'npmrc.authTokens.https://npm.foo.com/'
    at walk (/XXXserver.js:74759:15)
    at flatten (/XXX/server.js:74405:15)
    at validate (/XXX/server.js:74449:24)
    at Object.validate (/XXX/server.js:74911:20)

I guess it is becuase convict supports dot notation in the string sent to get() which gets confusing when the keys also have dots. Is there a workaround for this so we can use URLs as keys?

@noderat
Copy link

noderat commented May 21, 2018

I'm having this problem with String type as well. It looks like this isn't specific to Objects.

@madarche
Copy link
Collaborator

Sorry @jonaskello, no workaround that I know of.

The way convict parses all the objects is too complicated. This part is getting hard to maintain. The problem you are mentioning is a proof of it. A very good part of convict is the thorough tests which provide the needed cover and confidence when we modiy convict. A good thing would be to rewrite the whole parsing of objects. Taking advantage of ES6 features like the Map data structure, instead of using plain Objects, would be the way to go.

@lmeyerov
Copy link

lmeyerov commented Aug 28, 2019

This is hitting us pretty hard as the end-user is putting in config vals, not ourselves.

@lmeyerov
Copy link

Wrapping in [...] seems to protect against this, at least preventing crashing.

@A-312
Copy link
Contributor

A-312 commented Jan 6, 2020

#354 ;)

biancadanforth added a commit to mozilla/fxa that referenced this issue Apr 15, 2022
* add AppleIAP and PurchaseManager tests
* Updated App Store config to map appName to credentials instead of bundleId due to mozilla/node-convict#250.
  * Downstream effects include adding a new async static method to the AppleIAP module to initialize an App Store Server API client that can be called from PurchaseManager.querySubscriptionPurchase if the client isn't initialized by the time it's needed.
biancadanforth added a commit to mozilla/fxa that referenced this issue Apr 15, 2022
* add AppleIAP and PurchaseManager tests
* Updated App Store config to map appName to credentials instead of bundleId due to mozilla/node-convict#250.
  * Downstream effects include adding a new async static method to the AppleIAP module to initialize an App Store Server API client that can be called from PurchaseManager.querySubscriptionPurchase if the client isn't initialized by the time it's needed.
biancadanforth added a commit to mozilla/fxa that referenced this issue Apr 16, 2022
* add AppleIAP and PurchaseManager tests
* Updated App Store config to map appName to credentials instead of bundleId due to mozilla/node-convict#250.
  * Downstream effects include adding a new async static method to the AppleIAP module to initialize an App Store Server API client that can be called from PurchaseManager.querySubscriptionPurchase if the client isn't initialized by the time it's needed.
biancadanforth added a commit to mozilla/fxa that referenced this issue Apr 16, 2022
* add AppleIAP and PurchaseManager tests
* Updated App Store config to map appName to credentials instead of bundleId due to mozilla/node-convict#250.
  * Downstream effects include adding a new async static method to the AppleIAP module to initialize an App Store Server API client that can be called from PurchaseManager.querySubscriptionPurchase if the client isn't initialized by the time it's needed.
biancadanforth added a commit to mozilla/fxa that referenced this issue Apr 16, 2022
* add AppleIAP and PurchaseManager tests
* Updated App Store config to map appName to credentials instead of bundleId due to mozilla/node-convict#250.
  * Downstream effects include adding a new async static method to the AppleIAP module to initialize an App Store Server API client that can be called from PurchaseManager.querySubscriptionPurchase if the client isn't initialized by the time it's needed.
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

Successfully merging a pull request may close this issue.

5 participants