Skip to content

fix: shell test coverage and llm-update.sh formatting - #805

Merged
shunkakinoki merged 1 commit into
mainfrom
fix/shell-test-coverage
Feb 14, 2026
Merged

fix: shell test coverage and llm-update.sh formatting#805
shunkakinoki merged 1 commit into
mainfrom
fix/shell-test-coverage

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Feb 14, 2026

Copy link
Copy Markdown
Owner

Changes

  • Add scripts/llm-update.sh to coverage_spec.sh tracking list (fixes shell-test failure)
  • Add spec/llm_update_spec.sh with tests for the new script
  • Quote associative array keys in llm-update.sh to prevent shfmt from mangling file paths (e.g. config/openclaw/...config / openclaw / ...)
  • Apply formatter fixes to cliproxyapi config YAML files

Testing

  • make shell-test — 491 examples, 0 failures
  • make format — 0 files changed (stable)

Generated with Claude Code


Summary by cubic

Fix shell test coverage and shfmt formatting issues in llm-update.sh, and add a focused test suite for the script. Shell tests now pass and formatting is stable.

  • Bug Fixes
    • Track scripts/llm-update.sh in coverage_spec to prevent shell-test failure.
    • Add spec/llm_update_spec.sh to test strict mode, jq pretty names, placeholders, and template mapping.
    • Quote associative array keys in llm-update.sh to stop shfmt from splitting paths.
    • Apply small formatter cleanups to cliproxyapi config YAMLs.

Written for commit 97f10c1. Summary will update on new commits.

- Add scripts/llm-update.sh to coverage_spec.sh tracking list
- Add llm_update_spec.sh with tests for the new script
- Quote associative array keys to prevent shfmt from mangling paths
- Apply formatter fixes to cliproxyapi config YAML files

Entire-Checkpoint: 0e630aa734fa
Copilot AI review requested due to automatic review settings February 14, 2026 23:53
@mesa-dot-dev

mesa-dot-dev Bot commented Feb 14, 2026

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @shunkakinoki, 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 addresses shell test failures and improves code quality by enhancing test coverage for a new script, correcting formatting issues in a shell script to prevent shfmt conflicts, and applying minor formatting adjustments to YAML configuration files.

Highlights

  • Shell Test Coverage: The scripts/llm-update.sh script was added to the coverage_spec.sh tracking list to ensure it's included in shell test coverage, resolving a previous failure.
  • New Script Testing: A new test file, spec/llm_update_spec.sh, was introduced to provide dedicated tests for the llm-update.sh script, verifying its functionality and adherence to script properties.
  • Shell Script Formatting Fix: Associative array keys in scripts/llm-update.sh were quoted to prevent shfmt from incorrectly reformatting file paths, ensuring script integrity.
  • YAML Configuration Formatting: Formatting fixes were applied to config/cliproxyapi/config.template.yaml and config/cliproxyapi/config.tpl.yaml to align with style guidelines.
Changelog
  • config/cliproxyapi/config.template.yaml
    • Removed extraneous blank lines for formatting consistency.
  • config/cliproxyapi/config.tpl.yaml
    • Removed extraneous blank lines for formatting consistency.
  • scripts/llm-update.sh
    • Reformated conditional checks ([[ -f $MODELS ]] and [[ -f "$ROOT/$src" ]]) for improved readability.
    • Quoted associative array keys in the TEMPLATES declaration to prevent shfmt from misinterpreting file paths.
  • spec/coverage_spec.sh
    • Added scripts/llm-update.sh to the list of tracked scripts for shell test coverage.
  • spec/llm_update_spec.sh
    • Added a new shell spec file to test the scripts/llm-update.sh script's properties, dependencies, template processing, jq functions, and placeholder generation.
Activity
  • No human activity (comments, reviews, etc.) has been recorded for this pull request yet.
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.

@coderabbitai

coderabbitai Bot commented Feb 14, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Summary by CodeRabbit

  • Chores
    • Updated configuration template file formatting for consistency.
    • Enhanced configuration update script with completion status messaging.
    • Extended test coverage for configuration update processes.

Walkthrough

This pull request introduces formatting refinements to YAML configuration files, makes minor adjustments to the llm-update shell script (quoting and output messaging), and adds comprehensive test coverage for the llm-update script, along with updating the test coverage manifest.

Changes

Cohort / File(s) Summary
Configuration Whitespace
config/cliproxyapi/config.template.yaml, config/cliproxyapi/config.tpl.yaml
Removed blank lines in openai-compatibility and oauth-model-alias sections for denser YAML formatting; no structural or semantic changes.
Script Updates
scripts/llm-update.sh
Adjusted quoting in file existence test, reformatted error handling and loop blocks, updated associative array key definitions, and added completion message; functional behavior preserved with minor quoting adjustments that could affect paths with spaces.
Test Coverage
spec/coverage_spec.sh, spec/llm_update_spec.sh
Added llm-update.sh to coverage manifest and introduced new comprehensive test suite validating script syntax, dependency handling, template processing, jq formatting, and placeholder generation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • PR #421: Updates shellspec test coverage and adds shell script tests, directly related to the testing infrastructure changes in this PR.
  • PR #798: Modifies the same scripts/llm-update.sh and config files with overlapping formatting and test additions.

Suggested labels

refactor

Poem

🐰 The configs trimmed, the spaces gone,
New tests emerge to keep scripts strong,
With quoted keys and careful care,
Coverage blooms in testing's air!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/shell-test-coverage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mesa-dot-dev

mesa-dot-dev Bot commented Feb 14, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

This PR fixes shell test coverage for llm-update.sh, adds dedicated tests for it, addresses formatting issues in llm-update.sh by quoting associative array keys, and applies formatter fixes to cliproxyapi config YAML files.

What changed?

  • config/cliproxyapi/config.template.yaml: Removed two empty lines from openai-compatibility and oauth-model-alias sections (whitespace-only).
  • config/cliproxyapi/config.tpl.yaml: Removed two empty lines from the commented-out openai-compatibility section (whitespace-only).
  • scripts/llm-update.sh: Improved formatting and readability by refactoring conditionals, double-quoting keys in the TEMPLATES associative array, and adjusting whitespace in a sed command.
  • spec/coverage_spec.sh: Added scripts/llm-update.sh to the shell test coverage tracking list.
  • spec/llm_update_spec.sh: New file introducing a shpec test suite for scripts/llm-update.sh, verifying script properties, models.json dependency, template processing, jq pretty-printing, and placeholder generation.

Description generated by Mesa. Update settings

@cubic-dev-ai cubic-dev-ai Bot left a comment

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.

No issues found across 5 files

@shunkakinoki
shunkakinoki merged commit ed69044 into main Feb 14, 2026
27 of 32 checks passed
@shunkakinoki
shunkakinoki deleted the fix/shell-test-coverage branch February 14, 2026 23:55

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

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.

Code Review

This pull request improves shell script test coverage and formatting, especially for llm-update.sh. A high-severity command injection vulnerability was found in scripts/llm-update.sh due to unsafe sed usage with unvalidated input from models.json, requiring immediate attention to prevent Remote Code Execution (RCE). Further suggestions include fixing a potential bug in llm-update.sh related to unquoted variables and enhancing new tests to check for runtime behavior. The formatting changes are positive.

Comment thread scripts/llm-update.sh
echo "SKIP: $src"
continue
}
sed "${sed_args[@]}" "$ROOT/$src" >"$ROOT/$dst"

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.

security-high high

The sed command is vulnerable to command injection because it uses unvalidated input from models.json to construct substitution expressions. If a value in models.json contains the delimiter | followed by the e flag (e.g., value|e;s|a|b), GNU sed will execute the replacement as a shell command. This could lead to Remote Code Execution (RCE) if models.json is influenced by an attacker (e.g., via a malicious Pull Request).

To remediate this, ensure that all values from models.json are properly escaped before being added to sed_args. For example, you can escape the pipe character using Bash string replacement: ${value//|/\\|}. This should be applied to the value, pretty, and nondot variables where they are added to the sed_args array.

Comment thread scripts/llm-update.sh
MODELS="$ROOT/models.json"

[[ -f "$MODELS" ]] || { echo "ERROR: models.json not found" >&2; exit 1; }
[[ -f $MODELS ]] || {

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.

high

The $MODELS variable should be quoted to prevent issues with word splitting if the file path contains spaces. It's a good practice to always quote variables that hold file paths, as this will prevent bugs if the script is run from a directory with spaces in its name.

Suggested change
[[ -f $MODELS ]] || {
[[ -f "$MODELS" ]] || {

Comment thread spec/llm_update_spec.sh
Comment on lines +25 to +28
It 'exits if models.json is missing'
When run bash -c "grep 'models.json not found' '$SCRIPT'"
The output should include 'ERROR'
End

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 test only verifies that the error message string exists within the script file, but it doesn't test the actual runtime behavior. A more robust test would execute the script in a state where models.json is absent and assert that the script exits with a failure status code and prints the expected error message to stderr. This would provide stronger guarantees about the script's correctness.

Here's an example of how you could write a functional test for this case using shellspec features:

It 'exits if models.json is missing'
  # Temporarily move models.json to simulate its absence
  Before 'mv "$PWD/models.json" "$PWD/models.json.bak"'
  After 'mv "$PWD/models.json.bak" "$PWD/models.json"'

  When run script "$SCRIPT"
  The status should be failure
  The stderr should include 'ERROR: models.json not found'
End

This approach of testing behavior over implementation details could be applied to other tests in this file to make them more effective.

Copilot AI left a comment

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.

Pull request overview

This PR adds shell test coverage for the scripts/llm-update.sh script and applies formatting fixes to ensure compatibility with the shfmt formatter. The changes fix a shell test failure by adding the new script to the coverage tracking list and prevent shfmt from mangling file paths by quoting associative array keys.

Changes:

  • Added spec/llm_update_spec.sh with grep-based tests verifying script structure and functionality
  • Added scripts/llm-update.sh to the coverage tracking list in spec/coverage_spec.sh
  • Quoted associative array keys in scripts/llm-update.sh to prevent shfmt from splitting paths with slashes
  • Applied shfmt formatting (multi-line error handling blocks, removed spaces before redirection operators)
  • Removed extraneous blank lines in cliproxyapi YAML configuration files

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spec/llm_update_spec.sh New test file with grep-based tests for script properties, models.json handling, template processing, jq pretty-printing, and placeholder generation
spec/coverage_spec.sh Added scripts/llm-update.sh to the tracked scripts list in alphabetical order
scripts/llm-update.sh Quoted associative array keys, reformatted error handling blocks to multi-line format, removed space before output redirection operator
config/cliproxyapi/config.tpl.yaml Removed two extraneous blank lines for cleaner formatting
config/cliproxyapi/config.template.yaml Removed two extraneous blank lines to match template file formatting

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/llm-update.sh
MODELS="$ROOT/models.json"

[[ -f "$MODELS" ]] || { echo "ERROR: models.json not found" >&2; exit 1; }
[[ -f $MODELS ]] || {

Copilot AI Feb 15, 2026

Copy link

Choose a reason for hiding this comment

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

The variable $MODELS should be quoted in the test to be consistent with line 63 and to follow shell best practices. While the [[ ]] construct is more forgiving than [ ], it's safer and more consistent to quote variables to prevent potential issues with special characters or whitespace in paths.

Suggested change
[[ -f $MODELS ]] || {
[[ -f "$MODELS" ]] || {

Copilot uses AI. Check for mistakes.
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