influxdata / influxdata/influx-cli

influx write does not quote string field values in line protocol

Open
#340 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
75
Forks
22
PR merge metrics
No merged PRs in 30d

Description

The influx write command does not quote the field value of a string field and produces a bad request error.

Looking at [Line Protocol syntax reference](https://docs.influxdata.com/influxdb/cloud/reference/syntax/line-protocol/#whitespace), the second *unescaped* whitespace leads to the detection of the timestamp field?
So, there should be some kind of quoting happening here?
Or am I doing something inherently wrong?

Edit: Influx CLI 2.2.1 (git: 31ac78361b) build_date: 2021-11-09T21:19:29Z

Command using [extended CSV annotations](https://docs.influxdata.com/influxdb/cloud/reference/syntax/annotated-csv/extended/):
```
influx write dryrun --skipHeader 1 --debug --file --skipRowOnError --errors-file= --header '#constant measurement,smartcontract' --header '#constant tag,frequency,1d' --header '#constant tag,integration,1d' --header '#datatype ignored,tag,field:string,field:string,field:float,dateTime:2006-01-02' --header ',address,name,symbol,score,timestamp'
```

Example CSV:
```
"","address","name","symbol","score","timestamp"
"0","0xdac17f958d2ee523a2206206994597c13d831ec7","Tether: USDT Stablecoin","USDT","0.0032937814801044284","2021-09-01"
```

Example Output (dryrun):
```
smartcontract,address=0xdac17f958d2ee523a2206206994597c13d831ec7,frequency=1d,integration=1d name=Tether: USDT Stablecoin,symbol=USDT,score=0.0032937814801044284 1630454400000000000
```
Output Debug and Error:
```
2021/12/10 10:49:00 CsvTable{ dataColumns: 6 constantColumns: 3
measurement: &{Label:#constant measurement DataType:measurement DataFormat: LinePart:2 DefaultValue:smartcontract Index:-1 TimeZone:UTC ParseF: ComputeValue: escapedLabel:}
tag: &{Label:address DataType:tag DataFormat: LinePart:3 DefaultValue: Index:1 TimeZone:UTC ParseF: ComputeValue: escapedLabel:address}
tag: &{Label:frequency DataType:tag DataFormat: LinePart:3 DefaultValue:1d Index:-1 TimeZone:UTC ParseF: ComputeValue: escapedLabel:frequency}
tag: &{Label:integration DataType:tag DataFormat: LinePart:3 DefaultValue:1d Index:-1 TimeZone:UTC ParseF: ComputeValue: escapedLabel:integration}
field: &{Label:name DataType: DataFormat:string LinePart:4 DefaultValue: Index:2 TimeZone:UTC ParseF: ComputeValue: escapedLabel:name}
field: &{Label:symbol DataType: DataFormat:string LinePart:4 DefaultValue: Index:3 TimeZone:UTC ParseF: ComputeValue: escapedLabel:symbol}
field: &{Label:score DataType: DataFormat:float LinePart:4 DefaultValue: Index:4 TimeZone:UTC ParseF: ComputeValue: escapedLabel:score}
time: &{Label:timestamp DataType:dateTime DataFormat:2006-01-02 LinePart:5 DefaultValue: Index:5 TimeZone:UTC ParseF: ComputeValue: escapedLabel:}
}
Error: failed to write data: 400 Bad Request: unable to parse 'smartcontract,address=0xdac17f958d2ee523a2206206994597c13d831ec7,frequency=1d,integration=1d name=Tether: USDT Stablecoin,symbol=USDT,score=0.0032937814801044284 1630454400000000000': invalid boolean
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the supplied influx write dryrun command with the example extended CSV, then trace the CSV-to-line-protocol path used by the write command. Done means string field values are quoted correctly in generated line protocol, including the shown name and symbol values, and the resulting write no longer fails with a 400 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.