question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Crash when capturing JSON from invalid response

See original GitHub issue

When running a test that captures data from the response and the response does not match the expected shape it crashes

AssertionError [ERR_ASSERTION]: obj needs to be an object
    at JSONPath.query (/home/kenneth/load-testing/node_modules/jsonpath/lib/index.js:91:10)
    at extractJSONPath (/home/kenneth/load-testing/node_modules/artillery/core/lib/engine_util.js:481:26)
    at /home/kenneth/load-testing/node_modules/artillery/core/lib/engine_util.js:355:30
    at parseJSON (/home/kenneth/load-testing/node_modules/artillery/core/lib/engine_util.js:468:10)
    at /home/kenneth/load-testing/node_modules/artillery/core/lib/engine_util.js:347:7
    at /home/kenneth/load-testing/node_modules/async/lib/async.js:181:20
    at iterate (/home/kenneth/load-testing/node_modules/async/lib/async.js:262:13)
    at Object.async.forEachOfSeries.async.eachOfSeries (/home/kenneth/load-testing/node_modules/async/lib/async.js:281:9)
    at Object.async.forEachSeries.async.eachSeries (/home/kenneth/load-testing/node_modules/async/lib/async.js:214:22)
    at Object.captureOrMatch (/home/kenneth/load-testing/node_modules/artillery/core/lib/engine_util.js:333:9)

using 1.6.0-24

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
kennethlynnecommented, Sep 26, 2018

This patch solved it it seems

patch-package
--- a/node_modules/artillery/core/lib/engine_util.js
+++ b/node_modules/artillery/core/lib/engine_util.js
@@ -478,7 +478,12 @@ function extractJSONPath(doc, expr) {
     return '';
   }
 
-  let results = jsonpath.query(doc, expr);
+  let results;
+  try {
+    results = jsonpath.query(doc, expr);
+  } catch (err) {
+    return '';
+  }
 
   if (!results) {
     return '';

0reactions
hassycommented, Oct 19, 2018

New release with a fix will be out in the next couple of days. Thanks @kennethlynne!

Read more comments on GitHub >

github_iconTop Results From Across the Web

NodeJS Firebase App crash on Invalid JSON - Stack Overflow
The likeliest culprit for where this parsing is happening appears to be in your game API, since it seems to be handling your...
Read more >
Client crash calling Parse() method on invalid Json
Client crashes when calling Parse() method on an invalid Json string. Client terminates calling Progress.Json.ObjectModel.
Read more >
How to Fix The Invalid JSON Error in WordPress (Beginner's ...
Are you seeing the JSON response is not valid error on your WordPress site? Here's our step by step guide on how to...
Read more >
How to Fix the Invalid JSON Response Error in WordPress
The WordPress invalid JSON response error happens in the new Block Editor (AKA Gutenberg) when something goes wrong on your site.
Read more >
1. Warning: Invalid JSON response - DataTables
Typically, the response will consist of an error message from the program on the server which is being used to create the JSON,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found