logdna / logdna/env-config-node

Getting an undefined config should throw an error

Open
#10 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.