Skip to content

[Bug]: Lambda detector returns error if not run in Lambda #8629

@milas

Description

@milas

Component

Detector: AWS Lambda

Describe the issue you're facing

The detector does not fail gracefully if not run in Lambda, so can't be used generically.

This is inconsistent with, e.g. the EKS detector that no-ops once it determines it's not in-cluster, returns gracefully

Expected behavior

No error returned when detector is not used in Lambda env:

	// Lambda resources come from ENV
	lambdaName := os.Getenv(lambdaFunctionNameEnvVar)
	if lambdaName == "" {
		return empty, errNotOnLambda
	}

⬇️

	// Lambda resources come from ENV
	lambdaName := os.Getenv(lambdaFunctionNameEnvVar)
	if lambdaName == "" {
		return empty, nil
	}

Steps to Reproduce

	res, err := resource.New(
		ctx,
		resource.WithDetectors(
			lambdadetector.NewResourceDetector(),
		),
	)

And launch locally.

Operating System

Linux (distroless/container)

Device Architecture

ARM64

Go Version

1.25.7

Component Version

v0.66.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions