Skip to content

Drop dependency on m-mizutani/golambda#44

Merged
errm merged 16 commits intomasterfrom
errm/remove-golambda
Mar 27, 2026
Merged

Drop dependency on m-mizutani/golambda#44
errm merged 16 commits intomasterfrom
errm/remove-golambda

Conversation

@errm
Copy link
Copy Markdown
Member

@errm errm commented Mar 27, 2026

This pull request removes the dependency on the golambda package and replaces its logging and error handling with standard Go libraries and the new log/slog package. It also introduces a new utility in pkg/sqs for extracting S3 events from SQS batches, along with comprehensive unit tests. Additionally, the codebase is refactored to use clearer, more idiomatic error messages and logging, and a new logging handler is provided for AWS Lambda integration.

Key changes:

Dependency and logging refactor:

  • Removed the golambda package from the codebase and replaced its logging with Go's standard log/slog package, updating all affected files and import statements accordingly. (filter.go, pkg/models/rule.go, pkg/service/cloudtrail.go, pkg/service/slack.go, go.mod) [1] [2] [3] [4] [5] [6]
  • Updated error handling throughout the codebase to use standard errors and fmt.Errorf with descriptive messages instead of golambda.NewError and golambda.WrapError. (pkg/models/rule.go, pkg/service/cloudtrail.go, pkg/service/slack.go) [1] [2] [3] [4] [5] [6] [7] [8]

New features and utilities:

  • Added pkg/sqs/sqs.go with an ExtractEvents function to decode S3 event notifications from SQS batches containing SNS payloads, and provided thorough unit tests in pkg/sqs/sqs_test.go. [1] [2]
  • Introduced pkg/log/handler.go to provide a slog.Handler configured for AWS Lambda, including request metadata and configurable log levels via environment variables.

Testing and consistency improvements:

  • Updated tests to match new error messages and logging, ensuring consistency with the refactored error handling and logging approach. (pkg/service/cloudtrail_test.go, pkg/service/slack_test.go, rule_test.go) [1] [2] [3] [4] [5] [6] [7] [8] [9]

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the dependency on m-mizutani/golambda by switching to the upstream AWS Lambda Go runtime (aws-lambda-go/lambda) and replacing golambda-specific event/error/logging utilities with in-repo and standard-library equivalents.

Changes:

  • Replaced golambda-based Lambda entrypoint with lambda.Start and added SQS(SNS(S3)) extraction logic.
  • Migrated logging to log/slog with a new pkg/log handler to emit JSON logs enriched with Lambda context.
  • Replaced golambda error helpers with fmt.Errorf / errors.New across services and models; updated tests accordingly.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
uguisu.go Switches handler to lambda.Start, adds extractEvents, threads context.Context into processing, updates logging.
pkg/log/handler.go New slog JSON handler with LOG_LEVEL parsing and Lambda request context attributes.
pkg/service/slack.go Removes golambda errors/logger usage; uses stdlib errors + slog.
pkg/service/cloudtrail.go Removes golambda error wrapping; uses fmt.Errorf wrapping.
pkg/models/rule.go Removes golambda error construction; uses fmt.Errorf.
filter.go Replaces golambda logger usage with slog.
uguisu_test.go Updates tests to call new run(ctx, []events.S3Event) signature.
rule_test.go Updates rule tests to call new run(ctx, []events.S3Event) signature.
go.mod / go.sum Drops golambda and related transitive dependencies.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread uguisu.go Outdated
Comment thread uguisu.go Outdated
Comment thread uguisu.go Outdated
Comment thread uguisu_test.go Outdated
Comment thread pkg/service/slack.go Outdated
Comment thread uguisu.go Outdated
@errm errm force-pushed the errm/remove-golambda branch from b5aa815 to d168bdd Compare March 27, 2026 14:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread uguisu.go Outdated
Comment thread pkg/service/slack.go
Comment thread pkg/service/cloudtrail.go Outdated
Comment thread pkg/service/slack.go
@errm errm marked this pull request as ready for review March 27, 2026 15:41
@errm errm requested a review from bermannoah March 27, 2026 15:41
Copy link
Copy Markdown
Contributor

@bermannoah bermannoah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, thank you @errm !

@errm errm merged commit 726a663 into master Mar 27, 2026
2 checks passed
@errm errm deleted the errm/remove-golambda branch March 27, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants