Cannot convert object to primitive value

Open
#309 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript
Domain
backend

Research direction

The issue names an almanac debug line; start there and reproduce the failure with new Object(null). Done means debug logging can handle the value without throwing, with the chosen behavior covered by a regression test.

Written by the indexing model from the issue text.

Description

In almanac you have debug lines like this:

(0, _debug2.default)('almanac::constructor initialized runtime fact:' + fact.id + ' with ' + fact.value + '<' + _typeof(fact.value) + '>');

This line does string concatenation on fact.value which seems to also consider passed in params as facts. This basically requires that all passed in params have a toString() function such as what is available in a prototype. However, not all JavaScript variables are guaranteed to have a prototype or a toString() function (e.g. new Object(null)).

For starters, since this appears to be a debug log line, is there a way to disable this entirely? If not, this should be changed to use something like fast-safe-stringify or similar to convert param values to a String form.

Dominant language
JavaScript
Stars
3.1k
Forks
507
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

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.

More from CacheControl/json-rules-engine

All issues in CacheControl/json-rules-engine

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.