Skip to content

fix(skill): treat empty url param as absent when installing skills#1128

Merged
ilblackdragon merged 1 commit intonearai:stagingfrom
micsama:fix/skill-install-empty-url
Mar 15, 2026
Merged

fix(skill): treat empty url param as absent when installing skills#1128
ilblackdragon merged 1 commit intonearai:stagingfrom
micsama:fix/skill-install-empty-url

Conversation

@micsama
Copy link
Copy Markdown
Contributor

@micsama micsama commented Mar 13, 2026

Problem

LLMs sometimes pass "" for optional parameters instead of omitting them. Passing url: "" to skill_install caused the explicit-URL branch to match, attempting to fetch from an empty string and failing with an invalid URL error — instead of falling through to the catalog lookup as intended.

Fix

Add .filter(|s| !s.is_empty()) to the url parameter extraction so an empty string is treated the same as a missing field.

Tests

A unit test verifies the parameter filtering behaviour directly. The full execute path (catalog lookup + install) requires a real catalog and database and cannot be covered at the unit level.

Related

This is the same class of issue described in #1126 — LLMs expressing "optional param not provided" as "" rather than omitting the field. That issue covers time / routine; this PR addresses the same pattern in skill_install.

PR #1127 fixes the time tool variant. Open to feedback on whether a more centralised normalisation layer (as explored in #755) would be preferred over per-tool fixes.

@github-actions github-actions bot added scope: tool/builtin Built-in tools size: S 10-49 changed lines labels Mar 13, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 resolves an issue where Large Language Models (LLMs) sometimes provide empty strings for optional parameters instead of omitting them entirely. Specifically, it addresses the skill_install tool, ensuring that an empty url parameter is correctly interpreted as absent, allowing the system to proceed with a catalog lookup rather than failing due to an invalid URL. This improves the robustness of tool interactions with LLM outputs.

Highlights

  • Skill Installation Logic: Modified the skill_install tool to treat an empty string (" ") provided for the url parameter as if the parameter were absent. This prevents the tool from attempting to fetch from an invalid empty URL and ensures it falls back to catalog lookup as intended.
  • Unit Testing: Added a new unit test to specifically verify that an empty url parameter is correctly filtered and interpreted as None, confirming the fix's behavior.
Changelog
  • src/tools/builtin/skill_tools.rs
    • Modified the skill_install function to filter out empty strings for the url parameter.
    • Added a new unit test test_empty_url_param_is_treated_as_absent to validate the filtering behavior for empty URL parameters.
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.

@github-actions github-actions bot added risk: medium Business logic, config, or moderate-risk modules contributor: regular 2-5 merged PRs labels Mar 13, 2026
LLMs sometimes pass "" for optional parameters instead of omitting them.
Previously, passing url: "" to skill_install would match the explicit-URL
branch and attempt to fetch from an empty string, producing an invalid URL
error instead of falling back to the catalog lookup.

Fix by adding .filter(|s| !s.is_empty()) so an empty url is treated the
same as a missing field.

A unit test verifies the parameter filtering behaviour directly; the full
execute path (catalog lookup + install) requires a real catalog and database
and cannot be covered at the unit level.
@micsama micsama force-pushed the fix/skill-install-empty-url branch from 26eb121 to c8b27c0 Compare March 13, 2026 14:49
Copy link
Copy Markdown
Contributor

@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 correctly addresses an issue where an empty string for the url parameter in skill_install was causing an error. The fix, which treats an empty string as an absent parameter, is appropriate and is accompanied by a new unit test that verifies the behavior. My review includes a suggestion to centralize this parameter handling logic to improve maintainability, aligning with repository guidelines for refactoring duplicated code, which also aligns with the considerations you've mentioned in the pull request description.

Comment on lines +304 to +308
} else if let Some(url) = params
.get("url")
.and_then(|v| v.as_str())
.filter(|s| !s.is_empty())
{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

This logic to handle optional non-empty string parameters is also duplicated in the new test. As you mentioned in the PR description, this issue of LLMs passing "" for optional parameters is a recurring pattern.

To improve maintainability and avoid code duplication, consider extracting this logic into a helper function. A centralized helper in src/tools/tool.rs would be ideal, for example:

// in src/tools/tool.rs
pub fn optional_non_empty_str<'a>(params: &'a serde_json::Value, name: &str) -> Option<&'a str> {
    params
        .get(name)
        .and_then(|v| v.as_str())
        .filter(|s| !s.is_empty())
}

Using this helper would make the call site here cleaner and ensure consistency across different tools that face the same issue. Since modifying src/tools/tool.rs might be out of scope for this PR, this could be addressed in a follow-up. This suggestion aligns with the repository's guideline to prefer refactoring duplicated code into shared functions for better maintainability.

References
  1. When an issue is found in duplicated code, prefer refactoring into a shared function over applying localized fixes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's a great point — the pattern is definitely worth centralizing, especially given that it now appears in at least three tools. I intentionally kept this PR narrow to stay low-risk and easy to review, but I agree a shared helper would be the right long-term home for this logic. I'll track it as a follow-up. That said, it might be worth waiting to see how the broader discussion in #1126 lands first — if the project ends up preferring a dispatcher-level normalization (as in #755), a per-tool helper may not be needed at all.

@micsama micsama marked this pull request as ready for review March 13, 2026 14:50
Copy link
Copy Markdown
Collaborator

@zmanian zmanian left a comment

Choose a reason for hiding this comment

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

Clean fix with the right pattern. The .filter(|s| !s.is_empty()) idiom is correct and matches what #1127 does for the time tool. Test is pragmatic given the DB dependency. LGTM.

@ilblackdragon ilblackdragon merged commit 3f6d2ab into nearai:staging Mar 15, 2026
13 checks passed
@micsama micsama deleted the fix/skill-install-empty-url branch March 15, 2026 05:51
bkutasi pushed a commit to bkutasi/ironclaw that referenced this pull request Mar 28, 2026
…earai#1128)

LLMs sometimes pass "" for optional parameters instead of omitting them.
Previously, passing url: "" to skill_install would match the explicit-URL
branch and attempt to fetch from an empty string, producing an invalid URL
error instead of falling back to the catalog lookup.

Fix by adding .filter(|s| !s.is_empty()) so an empty url is treated the
same as a missing field.

A unit test verifies the parameter filtering behaviour directly; the full
execute path (catalog lookup + install) requires a real catalog and database
and cannot be covered at the unit level.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor: regular 2-5 merged PRs risk: medium Business logic, config, or moderate-risk modules scope: tool/builtin Built-in tools size: S 10-49 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants