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

feat: custom s3 endpoint url for 'plugin-node' #2176

Merged
merged 1 commit into from
Jan 23, 2025

Conversation

dtbuchholz
Copy link
Contributor

@dtbuchholz dtbuchholz commented Jan 12, 2025

Relates to

#2174, and builds upon #2379

Risks

Low. This affects only the plugin-node, and it changes logic in a way that is backward compatible.

Background

What does this PR do?

This changes the plugin-node to, optionally, use the set AWS_S3_ENDPOINT when generating URLs. If the value is set (e.g., http://localhost:8014), it instead uses this custom URL when reading/writing data. Closes #2174.

What kind of change is this?

Feature; improves the S3 plugin functionality.

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

The S3 plugin lacked a small feature, which was still enforcing public AWS S3 URLs, even if you're using a local provider.

For reference, I'm building a web3 native object storage layer, which has S3 compatability—called Basin: https://basin.textile.io. We have an S3 adapter that works with MinIO, boto3, etc. I tested this plugin against our adapter, and everything worked as expected (more on this below).

Documentation changes needed?

N/A

Testing

Where should a reviewer start?

If you'd like to test this flow, you'll need to use some local S3 compatible server. A popular one is MinIO. Once you have the server running, it should log the local port. You can then set the .env variable AWS_S3_ENDPOINT to this value (e.g., http://localhost:8014), and then call uploadFile.

Detailed testing steps

I tested this against our S3 adapter with both raw and resigned URLs. For example:

const s3 = runtime?.getService(ServiceType.AWS_S3) as IAwsS3Service;
const tempFile = path.join(os.tmpdir(), "test.txt");
writeFileSync(tempFile, "test content");
const fileContent = readFileSync(tempFile, "utf8");
elizaLogger.log("File content:", fileContent);
const { success, url, error } = await s3.uploadFile(
    tempFile,
    "",
    true,
    3600
);
console.log(url);
// Default `url` value: `http://localhost:8014/eliza/images/1736652765063-test.txt`
// If presigned: `http://localhost:8014/eliza/images/1736652765063-test.txt?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKEXAMPLES3S%2F20250112%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250112T033246Z&X-Amz-Expires=3600&X-Amz-Signature=ebd5aaaf39c272ff22017289327851512597cdc5e9549156cd1adee3426135de&X-Amz-SignedHeaders=host&x-id=GetObject`

This assumes AWS_S3_ENDPOINT / AWS_FORCE_PATH_STYLE are set.

Discord username

dtb_

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Hi @dtbuchholz! Welcome to the ai16z community. Thanks for submitting your first pull request; your efforts are helping us accelerate towards AGI. We'll review it shortly. You are now a ai16z contributor!

@dtbuchholz dtbuchholz force-pushed the 2174--plugin-node-custom-s3-url branch from 8f686e2 to 38f1a77 Compare January 12, 2025 04:08
@dtbuchholz dtbuchholz changed the base branch from main to develop January 12, 2025 04:08
@dtbuchholz dtbuchholz force-pushed the 2174--plugin-node-custom-s3-url branch from 38f1a77 to 59068c4 Compare January 12, 2025 04:09
odilitime
odilitime previously approved these changes Jan 12, 2025
@odilitime odilitime enabled auto-merge January 12, 2025 09:15
auto-merge was automatically disabled January 13, 2025 18:41

Head branch was pushed to by a user without write access

@dtbuchholz dtbuchholz force-pushed the 2174--plugin-node-custom-s3-url branch from 59068c4 to 0f0e3f4 Compare January 13, 2025 18:41
@dtbuchholz
Copy link
Contributor Author

@odilitime thanks for the quick review! i just rebased on the latest from develop (to resolve a pnpm lockfile mismatch) and force pushed the changes.

is there anything else I need to do on my end to get things merged? (I'm new to the repo and am just curious what the process looks like.)

@dtbuchholz dtbuchholz force-pushed the 2174--plugin-node-custom-s3-url branch from 0f0e3f4 to d5b4075 Compare January 23, 2025 04:34
Copy link
Contributor

coderabbitai bot commented Jan 23, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tcm390 tcm390 merged commit a20d512 into elizaOS:develop Jan 23, 2025
5 checks passed
@dtbuchholz dtbuchholz deleted the 2174--plugin-node-custom-s3-url branch January 27, 2025 16:19
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.

Add support for custom S3 endpoints in plugin-node
3 participants