influxdata / influxdata/influxdb

Flux metaquery causes "invalid memory address or nil pointer dereference"

Open
#21,186 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug panic team/query
Dominant language
Rust
Stars
31.7k
Forks
3.7k
Avg merge
13h 37m
Merged PRs (30d)
8

Description

If I run this query in cloud, I get a panic:

import "influxdata/influxdb/schema"
import "strings"

bucket = "apps"

schema.tagValues(bucket: bucket, tag: "_measurement")
  |> map(fn: (r) => {
    meas = r._value
    fields = schema.fieldKeys(bucket: bucket, predicate: (r) => r._measurement == meas) |> findColumn(column: "_value", fn: (key) => true)
    joinedFields = strings.joinStr(arr: fields, v: ", ")

    tags = schema.tagKeys(bucket: bucket, predicate: (r) => r._measurement == meas) 
      |> filter(fn: (r) => r._value != "_start" and r._value != "_stop" and r._value != "_measurement" and r._value != "_field")
      |> findColumn(column: "_value", fn: (key) => true)
    joinedTags = strings.joinStr(arr: tags, v: ", ")
    return {measurement: r._value, fields: joinedFields, tags: joinedTags}
  })
  |> group(columns: ["measurement"])

I get this panic: runtime error: invalid memory address or nil pointer dereference

It seems to work for some buckets, but not for others.

Contributor guide

Open the contributing guide

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.

Research direction

Start by reproducing the supplied Flux query in a bucket where it panics and comparing it with a bucket where it succeeds. Focus on the nested schema.tagValues, schema.fieldKeys, schema.tagKeys, findColumn, and strings.joinStr calls, then inspect the resulting panic details. Done means the query no longer produces an invalid memory address or nil pointer dereference for affected buckets.

Written by the indexing model from the issue text.

Assessment

Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.