duckduckgo / duckduckgo/content-scope-scripts
processAttr: NaN default value silently breaks identity check
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 70
- Forks
- 35
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 40
Description
Problem
processAttr(undefined, defaultValue) returns defaultValue via identity (return defaultValue), but if a feature author passes NaN as the default, downstream comparisons like result === expected will always be false because NaN !== NaN in JavaScript.
This was discovered via a property test that generated NaN as a default value. While feature authors don't currently pass NaN, the function has no guard against it.
Options
- Document that
NaNis not a supported default — cheapest, matches current reality - Normalize
NaNtoundefinedornull— defensive, prevents subtle bugs if a config accidentally producesNaN(e.g.parseInt('abc')) - No change needed — if the type system (
ConfigSetting) already prevents this
Context
Found in PR #2261. The property test was narrowed to realistic defaults as a workaround.
// src/utils.js — processAttr
if (configSetting === undefined) {
return defaultValue; // if defaultValue is NaN, callers can't compare the result
}
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 in src/utils.js at processAttr and review the property-test context from PR #2261. Decide which behavior should apply when defaultValue is NaN, then update the relevant implementation or documentation and ensure the property test reflects the chosen behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100