Skip to content

String serialization failure while escaping characters #241

@cTn-dev

Description

@cTn-dev

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:

  1. The "minimal" string i was able to reproduce the issue with {"prop":"{\"str\":\"test\"}"}
  2. This type of string escaping is the result of double stringification via JSON.stringify() (object containing a valid JSON string is stringified again)
  3. 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 working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy