fix: eliminate global logger side effects in mapper package#151
Open
fix: eliminate global logger side effects in mapper package#151
Conversation
Change MapperArguments.Validate() signature from Validate() to Validate() error so that callers can handle validation failures gracefully. This is required for library usage where log.Fatal() would terminate the host application. Update all callers (Upsert, Remove, RemoveByUsername, Get) to check and propagate the returned error. Add unit tests for all validation paths. Closes #143 Signed-off-by: Todd Ekenstam <todd_ekenstam@intuit.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Todd Ekenstam <todd_ekenstam@intuit.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #151 +/- ##
==========================================
+ Coverage 68.97% 69.98% +1.01%
==========================================
Files 12 12
Lines 593 593
==========================================
+ Hits 409 415 +6
+ Misses 165 162 -3
+ Partials 19 16 -3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
New() with isCommandline=false called log.SetOutput(io.Discard), which silenced the global logger for the entire process. Replace the unused LoggingEnabled field with a per-instance Logger, and convert WithRetry to a method so it can use the instance logger. Fixes #144. Signed-off-by: Todd Ekenstam <todd_ekenstam@intuit.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Todd Ekenstam <todd_ekenstam@intuit.com>
Error-path log messages in removeAuth and removeAuthByUser duplicated information already conveyed by the returned error. CLI callers surface these errors via log.Fatal, so users saw the same failure twice. Remove the redundant logs and improve the error messages to include the ARN. Signed-off-by: Todd Ekenstam <todd_ekenstam@intuit.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Todd Ekenstam <todd_ekenstam@intuit.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MapperArguments.Validate()to returnerrorinstead of callinglog.Fatal(), enabling library consumers to handle validation failures gracefully (fixes Bug: Validate() calls log.Fatal() preventing library error handling #143)log.SetOutput(io.Discard)call inNew()with a per-instance*log.Loggerfield onAuthMapper, so creating a silent mapper no longer silences logging for the entire process (fixes Bug: New() with isCommandline=false disables logging globally #144)WithRetryfrom a package-level function to anAuthMappermethod so it uses the instance loggerLoggingEnabledfield and theinit()function that mutated global log flagsUpsert,Remove,RemoveByUsername,Get) to check and propagate validation errors and use the instance loggerTest plan
go test ./...)🤖 Generated with Claude Code