Skip to content

[Bug] Go programs importing the DataProxy SDK may crash with no way to handle the error #11871

@marcv81

Description

@marcv81

What happened

https://github.com/apache/inlong/blob/master/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/util/id.go#L40

Using log.Fatal() in init() prevents programs importing the SDK to handle an eventual error. Any initialisation routine that may encounter errors should be called explicitly, and errors should be returned.

My problem: I cannot run Telegraf (https://github.com/influxdata/telegraf) on a machine with no network adapter. I do not expect InLong to work under these circumstances, but I do not expect that importing the SDK would prevent Telegraf from starting.

What you expected to happen

I expect the SDK to fail to initialise in a way that lets my program handle it. Whether the program should stop immediately or maybe continue with the InLong related features disabled should be left to my program.

How to reproduce

Run any Go program importing the DataProxy SDK on a machine without a network adapter.

import (
	"github.com/apache/inlong/inlong-sdk/dataproxy-sdk-twins/dataproxy-sdk-golang/dataproxy"
)

You can repro in a Docker container.

docker run --network none ...

Sample output:

2025/05/20 17:01:56 no ip

Environment

Tested on Linux, Ubuntu 24.04 (host and container). Also encountered on Mac CI machines.

InLong version

master

InLong Component

InLong DataProxy

Are you willing to submit PR?

  • Yes, I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

type/bugSomething is wrong

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions