Skip to content

Painless null pointer exception #24695

@biggiesmallsAG

Description

@biggiesmallsAG

Document:

      {
        "_index": "optik",
        "_type": "indicators",
        "_id": "AVwPUXjQo8Mgt9lhybim",
        "_score": 1,
        "_routing": "test1",
        "_parent": "test1",
        "_source": {
          "indicators_list": [
            {
              "indicator": "apple.com.au",
              "ptag_type": "",
              "ptag_analyst": "",
              "ptag_date": "1970-01-01T00:00:00.000000"
            }
          ]
        }
      }

Scripting:

POST optik/indicators/AVwPUXjQo8Mgt9lhybim/_update?parent=test1
{
  "script": {
    "lang": "painless",
    "inline": "int i=0; for (i = 0; i < doc['indicators_list'].length; i++) { if (doc['indicators_list'][i]['indicator'].value == 'apple.com.au') { doc['indicators_list'][i]['ptag_type'].value = params.ptag_type;}}",
    "params": {
      "ptag_type": "malicious"
    }
  }
}

Error:

{
  "error": {
    "root_cause": [
      {
        "type": "remote_transport_exception",
        "reason": "[h4M67tk][10.37.129.11:9300][indices:data/write/update[s]]"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "failed to execute script",
    "caused_by": {
      "type": "script_exception",
      "reason": "compile error",
      "script_stack": [],
      "script": "int i=0; for (i = 0; i < doc['indicators_list'].length; i++) { if (doc['indicators_list'][i]['indicator'].value == 'apple.com.au') { doc['indicators_list'][i]['ptag_type'].value = params.ptag_type;}}",
      "lang": "painless",
      "caused_by": {
        "type": "null_pointer_exception",
        "reason": null
      }
    }
  },
  "status": 400
}

Im at a dead end, would be nice to know where the null pointer is.. or why my script that is seemingly syntactically correct is failing..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions