-
Notifications
You must be signed in to change notification settings - Fork 71
Closed
Description
Expected Behavior:
Measurement with provided string is correctly escaped and written to the DB
Current Behavior:
Operation results in Cannot read property 'escapeChar' of undefined
error.
Steps/Code to Reproduce the Problem:
- The "minimal" string i was able to reproduce the issue with
{"prop":"{\"str\":\"test\"}"}
- This type of string escaping is the result of double stringification via JSON.stringify() (object containing a valid JSON string is stringified again)
- Partially-pseudo code to reproduce the issue (i don't really have any TS experience, i have adopted the 1.8 TS example for this, apologies/did what i could here)
import {ClientOptions, InfluxDB, Point} from '@influxdata/influxdb-client'
const username = 'username'
const password = 'password'
const database = 'telegraf'
const retentionPolicy = 'autogen'
const bucket = `${database}/${retentionPolicy}`
const clientOptions: ClientOptions = {
url: 'http://localhost:8086',
token: `${username}:${password}`,
}
const influxDB = new InfluxDB(clientOptions)
const writeAPI = influxDB.getWriteApi('', bucket)
const point = new Point('testMeasurement');
// THE IMPORTANT PART
point.stringField('testField', '{"prop":"{\"str\":\"test\"}"}');
writeAPI.writePoint(point)
writeAPI
.close()
.then(() => console.log('FINISHED'))
.catch(error => {
console.error(error)
})
The very likely cause is an edge case related to #205 on https://github.com/influxdata/influxdb-client-js/blob/master/packages/core/src/util/escape.ts#L60
Specifications:
- Version: InfluxDB 1.8.1 & influxdb-client-js 1.6.0
- Platform: Linux & node.js 12.18.3
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working