Skip to content

Conversation

@shahrear33
Copy link
Contributor

  • Add Artifacts class with get() method to retrieve artifacts by session ID and object ID
  • Support for different artifact types: img_ (returns Buffer), url_ (returns string URL), vid_ (returns cached file path)

- Add Artifacts class with get() method to retrieve artifacts by session ID and object ID
- Support for different artifact types: img_ (returns Buffer), url_ (returns string URL), vid_ (returns cached file path)
@gemini-code-assist
Copy link

Summary of Changes

Hello @shahrear33, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant new feature by adding an Artifacts client module. This module enables users to programmatically retrieve various types of artifacts, such as images, URLs, and videos, associated with specific sessions. It includes intelligent handling for different artifact types, including local caching for video files, and integrates seamlessly into the existing client structure.

Highlights

  • New Artifacts Client Module: Introduced a new Artifacts class to manage and retrieve various types of session-related artifacts.
  • Artifact Retrieval (get() method): Implemented a get() method that allows fetching artifacts by sessionId and objectId. It supports different return types based on the artifact type: Buffer for images and raw data, a string URL for url_ types, and a cached file path for vid_ (video) types.
  • Video Artifact Caching: Added functionality to cache video artifacts locally in a .vlmrun/cache directory within the user's home directory, returning the local file path upon retrieval.
  • Error Handling and Validation: Included validation for objectId format and content types for img_ and vid_ artifacts, throwing errors for mismatches or invalid formats.
  • Client Integration: Integrated the new Artifacts module into the main VlmRun client, making it accessible via client.artifacts.
  • Artifact Listing (list() method): A list() method was added as a placeholder, which currently throws a NotImplementedError.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new Artifacts client for fetching artifacts like images, URLs, and videos. The implementation is a good step forward, but I've found a few issues that need to be addressed. Most importantly, there is a critical path traversal security vulnerability in the video caching logic. Additionally, I've noted some areas for improvement regarding header handling and type safety. The new unit tests are a good start, but they currently lack coverage for the video artifact functionality, which is the most complex part of this new feature. Please see my detailed comments for suggestions.

}
}

const safeSessionId = sessionId.replace(/-/g, "");

Choose a reason for hiding this comment

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

critical

There is a path traversal vulnerability here. The sessionId is taken from user parameters and is not sufficiently sanitized before being used in path.join. An attacker could provide a sessionId with ../ sequences to write files outside of the intended VLMRUN_CACHE_DIR. This could lead to overwriting arbitrary files to which the user has write access. You should sanitize sessionId to only allow characters that are safe for a filename by using a whitelist approach.

Suggested change
const safeSessionId = sessionId.replace(/-/g, "");
const safeSessionId = sessionId.replace(/[^a-zA-Z0-9]/g, "");

).rejects.toThrow('Artifacts.list() is not yet implemented');
});
});
});

Choose a reason for hiding this comment

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

high

The test suite is missing coverage for the vid_ artifact type. This is the most complex part of the get method's logic, involving file system access, caching, and parsing the Content-Disposition header. Please add tests to cover these scenarios, including:

  • A video is successfully downloaded and cached.
  • The correct file path is returned.
  • If a file already exists in the cache, it is returned without a new download.
  • Correct extraction of the file extension from the Content-Disposition header.
  • The default .mp4 extension is used when the header is absent.

);

const data = Buffer.from(response.data);
const headers = response.headers as Record<string, string>;

Choose a reason for hiding this comment

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

medium

The type assertion as Record<string, string> is unsafe. Axios response header values can be a string, string[], or undefined. This could lead to runtime errors if a header has multiple values. It's safer to handle this possibility, for instance by using a more accurate type like axios.AxiosResponseHeaders and checking the type of the value before using it.

Comment on lines +107 to +108
const disposition =
headers["content-disposition"] || headers["Content-Disposition"];

Choose a reason for hiding this comment

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

medium

Axios normalizes response header keys to lowercase. Accessing headers["Content-Disposition"] is redundant and will likely fail to find the header. You should consistently use the lowercase version content-disposition.

Suggested change
const disposition =
headers["content-disposition"] || headers["Content-Disposition"];
const disposition = headers["content-disposition"];

* List artifacts for a session.
*
* @param sessionId - Session ID to list artifacts for
* @throws NotImplementedError - This method is not yet implemented

Choose a reason for hiding this comment

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

medium

The JSDoc indicates that this method throws a NotImplementedError, but the implementation throws a generic Error. To maintain consistency between documentation and behavior, you should update the JSDoc to reflect that an Error is thrown.

Suggested change
* @throws NotImplementedError - This method is not yet implemented
* @throws {Error} This method is not yet implemented

@shahrear33 shahrear33 merged commit e190672 into main Dec 18, 2025
3 checks 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.

2 participants