fix: make goth and ex_aws_auth optional dependencies#799
Merged
Conversation
Goth and ex_aws_auth were required deps but are only used by the
google_vertex (Goth OAuth) and amazon_bedrock (AWS SigV4) providers.
Mark them optional so users of other providers don't inherit them.
Because providers are compiled into :req_llm and discovered at runtime,
the Bedrock/Vertex modules must still compile when the optional deps are
absent. Rewrite the compile-time struct references (%AWSAuth.Credentials{},
%Goth.Token{}) to plain-map form so they no longer force the modules at
compile time. Add ensure-loaded guards that raise a clear 'add this
dependency' error when an IAM/ADC path is used without the dep.
Closes agentjido#798
fea7737 to
f953679
Compare
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
Closes #798.
gothandex_aws_authwere required dependencies, but they're only used by two providers:google_vertex— Goth, for Google Cloud OAuth (ADC / refresh tokens / workload identity / metadata server)amazon_bedrock— ex_aws_auth, for AWS Signature V4 signing (IAM credentials, STS, bidi streaming)Every user inherited both regardless of which provider they used. This marks them
optional: trueso they're only pulled in when explicitly added.The non-obvious part
optional: truealone is not sufficient. Provider modules are compiled into:req_llmand discovered at runtime (ReqLLM.Providers.discover_providers/0), so the Bedrock/Vertex modules must still compile when a downstream user omits the optional dep. They referenced%AWSAuth.Credentials{}and%Goth.Token{}as compile-time struct literals/patterns, which raise aCompileError(__struct__/1 is undefined) when the dep is absent.These are rewritten to plain-map form —
%{__struct__: Mod, ...}for pattern matches andstruct(Mod, ...)for construction — so they no longer force the module at compile time. Remote function calls (AWSAuth.sign_authorization_header,Goth.Token.fetch, etc.) compile fine without the dep and only need runtime guarding.Changes
mix.exs— both deps markedoptional: true.amazon_bedrock.ex,amazon_bedrock/sts.ex,bedrock/bidi_stream.ex,google_vertex/auth.ex.ensure_ex_aws_auth!/0at Bedrock credential-resolution time (the pre-existing guard fired too late — afterAWSAuth.Credentials.from_map/from_envwas already called).Code.ensure_loaded(Goth.Token)on the Vertex ADC/metadata path.~> 1.3→~> 1.4).Verification
mix compile+ Bedrock/Vertex test suites: 180 tests, 0 failures.mix format --check-formattedandmix credoclean on changed files.CompileError), neither dep is fetched, both providers still appear inReqLLM.Providers.list/0, and exercising an IAM/ADC path raises the friendly dependency error rather than a rawUndefinedFunctionError.Known gap
The bidirectional-streaming path (
bidi_stream.ex, Nova Sonic) constructs credentials without an upfront guard, so it would raise a rawUndefinedFunctionErrorrather than the friendly message if ex_aws_auth is missing. Left as-is since it's a niche path — happy to add a guard for symmetry if preferred.