Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Goat Plugin + AWS S3 Service error when env vars absent #985

Merged

Conversation

jnaulty
Copy link
Contributor

@jnaulty jnaulty commented Dec 11, 2024

Relates to:

#941 and #898

Errors when running agent were:
TypeError: Cannot read properties of null (reading 'getChain')


 ["✓ Service video initialized successfully"] 

Initializing AwsS3Service
 ⛔ ERRORS
   Failed to initialize service aws_s3: 
   {} 

 ⛔ ERRORS
   Error starting agent for character trump: 
   {} 

Error: Missing required AWS credentials in environment variables
    at _AwsS3Service.initialize (file:///home/jnaulty/github.com/ai16z/eliza/packages/plugin-node/dist/index.js:1890:19)
    at AgentRuntime.initialize (file:///home/jnaulty/github.com/ai16z/eliza/packages/core/dist/index.js:3245:31)
    at async startAgent (file:///home/jnaulty/github.com/ai16z/eliza/agent/src/index.ts:344:9)
    at async startAgents (file:///home/jnaulty/github.com/ai16z/eliza/agent/src/index.ts:368:13)
 ⛔ ERRORS
   Error starting agents: 
   {} 

 ["◎ Chat started. Type 'exit' to quit."] 

You:  ["✓ Server running at http://localhost:3000/"] 

Risks

  • none, improves usability when specific env variables are not present

Background

What does this PR do?

  • fixes issue when environment variables are not set for goat + node plugins

What kind of change is this?

Bug fixes (non-breaking change which fixes an issue)

Why are we doing this? Any context or related work?

  • main branch does not run unless AWS env variables are set and Alchemy API (for GOAT)
    • NodePlugin is now only created when all required AWS credentials are present (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, AWS_S3_BUCKET)
  • GoatPlugin is now only created when ALCHEMY_API_KEY is present
  • Added type annotations for plugins to handle undefined cases

These changes prevent unnecessary plugin initialization when required credentials are missing and improve type safety.

Issues introduced in: #941 and #898

Documentation changes needed?

none

Testing

Where should a reviewer start?

Detailed testing steps

None, automated tests are fine.

Discord username

@crypto__john

- NodePlugin is now only created when all required AWS credentials are present
  (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, AWS_S3_BUCKET)
- GoatPlugin is now only created when ALCHEMY_API_KEY is present
- Added type annotations for plugins to handle undefined cases

These changes prevent unnecessary plugin initialization when required
credentials are missing and improve type safety.

Issues introduced in: elizaOS#941 and
elizaOS#898
@jnaulty jnaulty marked this pull request as ready for review December 11, 2024 06:56
@odilitime
Copy link
Collaborator

Ugh nodePlugin provided a lot of services, we need to fix it by not requiring those.

@jnaulty
Copy link
Contributor Author

jnaulty commented Dec 11, 2024

it might be wise to split out the AWS S3 into a separate plugin.

@odilitime
Copy link
Collaborator

Yes I’ll have to go over the history and see what changed it. It didn’t used to be this way

@jnaulty
Copy link
Contributor Author

jnaulty commented Dec 11, 2024

I believe this was introduced in PR: #941

@jnaulty
Copy link
Contributor Author

jnaulty commented Dec 11, 2024

ok, @odilitime -- I updated the change to load the node plugin (so all the other services can be accessed)
aws s3 service is still registered, but only works if the env vars are present.

@jnaulty jnaulty changed the title feat: make NodePlugin and GoatPlugin creation conditional fix: Goat Plugin + AWS S3 Service error when env vars absent Dec 11, 2024
Copy link

@AgustinRamiroDiaz AgustinRamiroDiaz left a comment

Choose a reason for hiding this comment

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

This is currently broken on main, it'd be nice to merge this PR to have it fixed :D

Comment on lines +387 to +392
let goatPlugin: any | undefined;
if (getSecret(character, "ALCHEMY_API_KEY")) {
goatPlugin = await createGoatPlugin((secret) =>
getSecret(character, secret)
);
}

Choose a reason for hiding this comment

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

nit: In order to not duplicate the secret check, you could do

Suggested change
let goatPlugin: any | undefined;
if (getSecret(character, "ALCHEMY_API_KEY")) {
goatPlugin = await createGoatPlugin((secret) =>
getSecret(character, secret)
);
}
const getGoatPlugin = async () => await createGoatPlugin((secret) =>
getSecret(character, secret)
);

and then later on line 440 do

            getSecret(character, "ALCHEMY_API_KEY") ? getGoatPlugin() : null,

@odilitime odilitime merged commit 8f1ce72 into elizaOS:main Dec 11, 2024
1 check passed
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