in @cmd/entire/cli/agent/external/capabilities.go add a nil check in the Wrap method to…
- User
in @cmd/entire/cli/agent/external/capabilities.go add a nil check in the Wrap method to ensure
eais not nil Assistant
Added a nil check for
eaat the start ofWrap()that returnsnilearly, preventing a nil pointer dereference when accessingea.info.Capabilities.- User
Wrap should also return an error and report
"unable to wrap nil agentin that case Assistant
Let me check how
Wrapis called to update the callers too.Assistant
Let me check the caller in discovery.go to see the context.
Assistant
Now I'll update
Wrapto return an error and update the caller in discovery.go.Assistant
Now update the caller in discovery.go.
Assistant
Let me check the imports in discovery.go to make sure
slogis already imported.Assistant
Good,
slogandloggingare already imported. Now let me update the test file callers.Assistant
I need to update all 7 test call sites. Let me use replace_all since the pattern
wrapped := Wrap(ea)is consistent.Assistant
Let me verify the test file doesn't have a shadowed
errissue sinceea, err := New(...)is right before.Assistant
Good —
erris reused with=via:=short variable declaration (Go allows re-declaring with:=when at least one variable on the left is new, whichwrappedis). This is fine.Now let me run the tests to make sure everything compiles and passes.
Assistant
All compiles and tests pass. Here's a summary of the changes:
capabilities.go:Wrapnow returns(agent.Agent, error)and returns an error with message"unable to wrap nil agent"wheneais nil. Added"errors"import.discovery.go: Updated the caller to handle the error — logs and skips the agent on failure.external_test.go: Updated all 7 test call sites to handle the new error return.