# \[Filebeat 8.6.1 - httpjson\] invalid memory address or nil pointer dereference

**URL:** <https://discuss.elastic.co/t/filebeat-8-6-1-httpjson-invalid-memory-address-or-nil-pointer-dereference/326365>\
**Category:** Beats\
**Tags:** filebeat\
**Created:** [February 23, 2023, 6:47pm UTC](https://discuss.elastic.co/t/filebeat-8-6-1-httpjson-invalid-memory-address-or-nil-pointer-dereference/326365 "2023-02-23T18:47:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marrc.rousseau](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@marrc.rousseau](https://discuss.elastic.co/u/marrc.rousseau)\
**Post date:** [February 23, 2023, 6:47pm UTC](https://discuss.elastic.co/t/filebeat-8-6-1-httpjson-invalid-memory-address-or-nil-pointer-dereference/326365/1 "2023-02-23T18:47:27Z")

</div>

Hello,

I try to use httpjson with "chain" and "steps" but I'm stuck on this error "invalid memory address or nil pointer dereference".

Here is what I did:

1. a simple httpjson to call an API and get host IDs

```auto
filebeat.inputs:
- type: httpjson
  request.url: https://xxx/api/hosts?per_page=2&thin=true
  request.method: GET
  auth.basic:
    user: xxx
    password: xxx
output.console:
  pretty: true

```

Result is

```auto
{
    "total": 62,
    "subtotal": 62,
    "page": 1,
    "per_page": 2,
    "search": null,
    "sort": {
        "by": null,
        "order": null
    },
    "results": [
        {
            "id": 193,
            "name": "xxxx"
        },
        {
            "id": 101,
            "name": "yyy"
        }
    ]
}

```

Looks good ....

1. now I want to use these ids to do a second api call

```auto
filebeat.inputs:
- type: httpjson
  request.url: https://xxx/api/hosts?per_page=2&thin=true
  request.method: GET
  auth.basic:
    user: xxx
    password: xxx
  chain:
    - step:
        request.url: https://xxx/api/hosts/$.results[:].id/errata
        request.method: GET
        replace: $.results[:].id
output.console:
  pretty: true

```

And got this error when I start "filebeat -c test.yml -e"

> {"log.level":"error","@timestamp":"2023-02-23T19:45:44.138+0100","log.logger":"input.httpjson-stateless","log.origin":{"file.name":"compat/compat.go","file.line":124},"message":"Input 'httpjson-stateless' failed with: runtime error: invalid memory address or nil pointer dereference","service.name":"filebeat","id":"E49CFF25B852F300","ecs.version":"1.6.0"}

Any idea ?  
Any help is welcome 😉

&nbsp;  
&nbsp;  
&nbsp;

_Note_ :

Looks like there's a typo in ELK documentation : [https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-httpjson.html#chain-step-replace](https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-input-httpjson.html#chain-step-replace)

```auto
(...)
  chain:
    # second call
    - step:
      request.url: https://example.com/services/data/v1.0/$.records[:].id/export_ids
(...)

```

This code will create an error :

> Exiting: Failed to start crawler: starting input failed: error while initializing input: both step & while blocks in a chain cannot be empty accessing 'filebeat.inputs.0' (source:'/etc/filebeat/test4.yml')

You need to add two more white spaces in front of lines under "- step:"

```auto
(...)
  chain:
    # second call
    - step:
        request.url: https://example.com/services/data/v1.0/$.records[:].id/export_ids
(...)

```

---

<div class="post-metadata">

**Author:** ![marrc.rousseau](https://avatars.discourse-cdn.com/v4/letter/m/2acd7d/32.png) [@marrc.rousseau](https://discuss.elastic.co/u/marrc.rousseau)\
**Post date:** [February 24, 2023, 8:19am UTC](https://discuss.elastic.co/t/filebeat-8-6-1-httpjson-invalid-memory-address-or-nil-pointer-dereference/326365/2 "2023-02-24T08:19:25Z")

</div>

Finally found a workaround  
Looks like auth.basic is not compatible with chain/step. Bug or documentation misleading ?

This one works

```auto
filebeat.inputs:
- type: httpjson
  request.url: https://xxx/api/hosts?per_page=2&thin=2
  request.transforms:
    - set:
        target: header.Authorization
        value: 'Basic xxxxxxxxxxxxxxxx'
  chain:
    - step:
        request.url: https://xxx/api/hosts/$.results[:].id/errata?type=security
        request.method: GET
        replace: $.results[:].id
        request.transforms:
          - set:
              target: header.Authorization
              value: 'Basic xxxxxxxxxx'
output.console:
  pretty: true

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 24, 2023, 10:20am UTC](https://discuss.elastic.co/t/filebeat-8-6-1-httpjson-invalid-memory-address-or-nil-pointer-dereference/326365/3 "2023-03-24T10:20:03Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
