logdna / logdna/env-config-node
Getting an undefined config should throw an error
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Consider the following:
```js
const Config = require('@logdna/env-config')
const config = new Config([
Config.string('loglevel').default('info')
, Config.number('port').default(3000)
])
const foo = config.get('something-else') // happily returns undefined
// do something important with foo...
```
Rather than just silently failing in this case (e.g. a typo in the config name, or you just forgot to add it...) we should throw an error.
While there may be valid use cases for "dynamic" configuration in which the properties are _expected_ to be (potentially) unknown, the default behavior should be more strict.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the Config constructor and the config.get entry point shown in the issue to understand how declared and unknown names are handled. Define the default error behavior while accounting for the mentioned dynamic-configuration use case, then add regression coverage showing that an undefined name throws and declared names still work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100