Invalid memory address or nil pointer only on linux

I use a Mac to develop our in-house accounting tool and on a Mac M1 it runs without fault, debugs, compiles etc.

But when I copy the code to our Debian 12 server, and try to run it, the same code throws a fatal panic “Invalid memory address or nil pointer” on an api response. Apart from the OS the setup is the same, the latest go version etc.

I check for Errors on the response, but I get the panic when it try to use the payload…

response, err := client.FinancesAPI.ListFinancialEventGroups(&filter)
if err != nil {
fmt.Println(“Error”, err)
gl := response.ResponseBody.Payload.FinancialEventGroupList. # here it throws the panic.

Is there something relevant only for linux, I was not aware of ?

Hi @Markus_Bolder, welcome to the forum.

One of the dot-chain steps seems to evaluate to nil. But which one? (That’s why I am not exactly a fan of dot-chaining.)

I’d split them up into several lines and watch at which line the panic exactly occurs.

Or maybe just dump the whole response to stdout using, for example, fmt.Printf("%#v\n", response), and see if all expected fields exist.

BTW, the dot at the end of FinancialEventGroupList. looks like it shouldn’t be there. Typo when adding the code here?

Edited to add:

Maybe the problem occurs earlier. What are the contents of filter on Mac vs Debian?

Hi Christoph,

I can show you the complete sample code. The code requests from the amazon sp api a list of financial events for a sample period of the last 10 days.

package main

import (

sp_api ""


func main() {
log := logger.New(logger.LvlError)
c := sp_api.Config{
ClientID: “”,
ClientSecret: “”,
RefreshToken: “”,
IAMUserAccessKeyID: “”,
IAMUserSecretKey: “”,
Region: constants.EUWest,
RoleArn: “”,
Endpoint: constants.Europe,
Log: log,
client, err := sp_api.NewClient(c)
if err != nil {
defer client.Close()
maxre := 100
now := apis.JsonTimeISO8601{time.Now().Add(time.Hour * -2)}
from := apis.JsonTimeISO8601{time.Now().Add(time.Hour * 24 * -10)}
filter := finances.ListFinancialEventGroupsFilter{MaxResultsPerPage: &maxre, FinancialEventGroupStartedBefore: &now, FinancialEventGroupStartedAfter: &from}
response, err := client.FinancesAPI.ListFinancialEventGroups(&filter)
if err != nil {
fmt.Println(“Error”, err)
gl := response.ResponseBody.Payload.FinancialEventGroupList

On my Mac the responses are correct:

&{200 0x14000dec540 }

[{0x14000f02000 0x14000f02010 0x14000f02020 0x14000f02050 2023-12-01 11:28:34 +0000 UTC } {0x14000f02090 0x14000f020a0 0x14000f020b0 0x14000f020c0 2023-12-02 05:28:44 +0000 UTC 0x14000f020f0 0x14000f02100 0x14000f02110 2023-11-24 12:26:54 +0000 UTC 2023-12-01 11:28:34 +0000 UTC}]

On linux the same code produces:

&{200 }

fatal panic

I understand the “nil-panic”, but not why the response is nil in the first place given the fact the credentials and filters where accepted, hence the 200. Also, the internal logger doesn’t produce any warnings or errors.

The response is &{200, nil, nil}. Amazon’s API seems perfectly fine with returning a nil ResponseBody and a nil ErrorList at the same time. I peeked into the sources of ListFinancialEventGroups but cannot see where or how it would do that.

The only difference that I can see is in the filter: it is set based on the current date & time.

  • Is the Debian system in a different time zone?
  • Is the time zone set correctly there?

If everything fails, I would suggest taking this strange API behavior as a given and treating the nil body as a special way of the API saying “no results”.

May be It’s amazon bug on linux system.

When attempting to deploy the same code on a Linux-based server, specifically Ubuntu 20.04, I’m an unexpected runtime panic. The error message cryptically points to an “invalid memory address or nil pointer,” and it occurs when I’m handling responses from an external API. I’ve checked for errors in the response, but the panic is triggered when attempting to access the payload data.

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