Skip to content

Comments

Add kit directory validation during installation#353

Merged
sayalibhavsar merged 1 commit intomainfrom
gh-323
Feb 24, 2026
Merged

Add kit directory validation during installation#353
sayalibhavsar merged 1 commit intomainfrom
gh-323

Conversation

@sayalibhavsar
Copy link
Contributor

Description

This PR adds inline validation to install.sh that checks for missing kit files/directories specified in config templates and displays clear warnings during installation.

Before/After Comparison

Before: Installation completed silently even if required kits were missing, causing wrappers to fail later without clear indication why.
After: Installation displays a formatted warning listing all missing kits with their paths and guidance on how to resolve the issue.

Documentation Check

No documentation updates needed as this is a non-blocking warning feature that enhances existing installation behavior without changing user workflows.

Clerical Stuff

This closes #323
Relates to JIRA: RPOPC-700

@qodo-code-review
Copy link

Review Summary by Qodo

Add kit directory validation to installation script

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Adds validation for kit directories during installation
• Checks template files for missing kit paths specified in upload_extra
• Displays formatted warning with missing kit details and guidance
• Handles both array and string format kit specifications
Diagram
flowchart LR
  A["Installation Complete"] --> B["Validate Kit Directories"]
  B --> C["Parse Template Files"]
  C --> D["Extract upload_extra Values"]
  D --> E["Check Path Existence"]
  E --> F{Missing Kits?}
  F -->|Yes| G["Display Warning Message"]
  F -->|No| H["Continue"]
  G --> H
Loading

Grey Divider

File Changes

1. bin/install.sh ✨ Enhancement +70/-0

Add kit directory validation with warning display

• Added kit directory validation logic after installation record creation
• Iterates through config template files to extract upload_extra values
• Handles both array and space-separated string formats for kit paths
• Displays formatted warning message listing missing kits with template names and paths
• Provides guidance on resolving missing kit issues

bin/install.sh


Grey Divider

Qodo Logo

@qodo-code-review
Copy link

qodo-code-review bot commented Feb 24, 2026

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (0) 📎 Requirement gaps (1)

Grey Divider


Action required

1. /home/uploads warning missing 📎 Requirement gap ⛯ Reliability
Description
The install script changes add warnings for missing kit paths but do not check whether
/home/uploads exists and emit the required non-blocking warning text. This fails the specified
installation-time visibility requirement for missing /home/uploads.
Code

bin/install.sh[R212-215]

+# Validate kit directories specified in templates
+echo ""
+echo "Validating kit directories..."
+
Evidence
PR Compliance ID 7 requires an explicit /home/uploads existence check and an exact warning string
when missing; the newly added installation validation block only validates upload_extra kit paths
from templates and prints a different warning, with no /home/uploads check present in the
added/modified lines.

Warn (non-blocking) if /home/uploads directory is missing during installation
bin/install.sh[212-280]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The install script must warn (without failing) if `/home/uploads` is missing, and the warning text must match the compliance requirement exactly.

## Issue Context
Current PR adds kit-path validation warnings, but does not implement the required `/home/uploads` presence check and exact warning string.

## Fix Focus Areas
- bin/install.sh[212-215]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. upload_extra comma parsing 🐞 Bug ✓ Correctness
Description
The new validator splits string upload_extra values on spaces only, but the repo’s
documented/implemented contract treats upload_extra as a comma-separated list (often normalized by
converting commas to spaces). This can create false warnings (e.g., checking path1,path2 as one
non-existent path) and reduce trust in installer output.
Code

bin/install.sh[R246-248]

+        # It's a string, split by spaces
+        IFS=' ' read -ra paths <<< "$upload_extra"
+        for path in "${paths[@]}"; do
Evidence
install.sh splits only on spaces, while docs and the main driver script (bin/burden) normalize
commas to spaces before iterating upload_extra entries.

bin/install.sh[246-248]
docs/test_config_files.md[124-127]
bin/burden[823-831]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`bin/install.sh` validates `upload_extra` by splitting string values on spaces only. Elsewhere (docs + `bin/burden`) `upload_extra` is treated as a comma-separated list (commas normalized to spaces). This mismatch can cause false missing-kit warnings.

### Issue Context
- `upload_extra` is used to build `upload_files.yml` in `bin/burden`, which normalizes commas to spaces.
- Documentation also describes comma-separated lists.

### Fix Focus Areas
- bin/install.sh[246-255]

### Suggested change
- For the string case, normalize commas to spaces before splitting, e.g.:
 - `upload_extra_norm=${upload_extra//,/ }`
 - then split on whitespace: `read -ra paths &lt;&lt;&lt; &quot;$upload_extra_norm&quot;`
- Consider trimming/ignoring empty tokens after normalization.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Checks -e not file 🐞 Bug ⛯ Reliability
Description
The validator uses [[ -e ... ]] (exists) for upload_extra paths, but later code paths treat
these as files to upload (and verify with -f). A directory at that path would pass validation yet
fail later during upload, defeating the PR’s goal of early clarity.
Code

bin/install.sh[R239-242]

+            if [[ "$path" != "none" ]] && [[ -n "$path" ]]; then
+                if [[ ! -e "$path" ]]; then
+                    missing_kits+=("$template_name:$path")
+                fi
Evidence
install.sh treats any existing path as OK (-e), while bin/burden explicitly requires regular
files (-f) for upload_extra, writes them into upload_files.yml, and the ansible role uploads
them via scp (no -r).

bin/install.sh[239-242]
bin/burden[823-831]
bin/burden[1118-1127]
ansible_roles/roles/actual_upload_extra/tasks/main.yml[10-13]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The installer validation uses `-e` (path exists), which allows directories. However, `upload_extra` is later treated as a file list (`bin/burden` verifies with `-f`) and uploaded via `scp` without `-r`. As a result, directories can pass validation but still fail later.

### Issue Context
- `bin/burden` is the main driver generating `upload_files.yml` and requires `-f` for `upload_extra`.
- `actual_upload_extra` uses plain `scp` (no recursive copy).

### Fix Focus Areas
- bin/install.sh[238-255]

### Suggested change
- Replace `[[ ! -e &quot;$path&quot; ]]` with checks that match expected type:
 - Prefer: `[[ ! -f &quot;$path&quot; ]]` for missing/invalid kit file.
 - Optionally add a separate warning if `[[ -d &quot;$path&quot; ]]` (exists but is a directory) explaining it will not upload correctly.
- Apply the same logic in both the array and string branches.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. readlink can exit 🐞 Bug ⛯ Reliability
Description
Because the script runs with set -e, config_dir=$(readlink -f "config") can terminate the
installer if readlink fails or config is missing, even though this feature is intended to be
warning-only. config_dir is only used for messaging, so it should not be a hard failure point.
Code

bin/install.sh[R216-218]

+missing_kits=()
+config_dir=$(readlink -f "config")
+
Evidence
set -eu is enabled globally, and the new readlink -f invocation is unguarded (no fallback), so a
failure would abort the install at the very end for what is intended to be a non-blocking warning
step.

bin/install.sh[20-21]
bin/install.sh[216-218]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`bin/install.sh` runs with `set -e`, so an unguarded `readlink -f &quot;config&quot;` failure will abort the installer, despite this block being intended as non-blocking warnings.

### Issue Context
`config_dir` is only used in the final informational message, not for core installation steps.

### Fix Focus Areas
- bin/install.sh[216-218]

### Suggested change
- Make `config_dir` resolution non-fatal, e.g.:
 - `config_dir=$(readlink -f &quot;config&quot; 2&gt;/dev/null || echo &quot;config&quot;)`
 - or check directory existence before calling readlink.
- Keep the validation block warning-only even if config path resolution fails.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@github-actions
Copy link

This relates to RPOPC-700

@sayalibhavsar sayalibhavsar self-assigned this Feb 24, 2026
@sayalibhavsar sayalibhavsar added the group_review_lgtm Indicates approval after a group review meeting label Feb 24, 2026
Comment on lines +212 to +215
# Validate kit directories specified in templates
echo ""
echo "Validating kit directories..."

Choose a reason for hiding this comment

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

Action required

1. /home/uploads warning missing 📎 Requirement gap ⛯ Reliability

The install script changes add warnings for missing kit paths but do not check whether
/home/uploads exists and emit the required non-blocking warning text. This fails the specified
installation-time visibility requirement for missing /home/uploads.
Agent Prompt
## Issue description
The install script must warn (without failing) if `/home/uploads` is missing, and the warning text must match the compliance requirement exactly.

## Issue Context
Current PR adds kit-path validation warnings, but does not implement the required `/home/uploads` presence check and exact warning string.

## Fix Focus Areas
- bin/install.sh[212-215]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@github-actions
Copy link

PullHero Review

Provider: generativelanguage.googleapis.com Model: gemini-2.0-flash

Okay, I've reviewed the changes to bin/install.sh. This commit adds a validation step to the installation script that checks for the existence of kit directories specified in the template files.

Overall Assessment:

The changes look good overall. This addresses a common issue where Zathras would be configured to use kits that don't exist, leading to confusing errors later on. The warning message is clear and actionable.

Detailed Feedback:

  • Code Quality and Maintainability: The code is generally well-structured and easy to read. The use of yq to extract the upload_extra value is appropriate.

  • Potential Bugs or Security Issues: No immediate security concerns. However, the script relies on the user providing correct paths in the template files. It might be beneficial to add more robust validation of the paths themselves (e.g., checking for absolute paths, preventing directory traversal). This is outside the scope of the current changes but could be a future enhancement.

  • Adherence to Project Conventions: The changes adhere to the existing project style and conventions.

  • Documentation Completeness: The commit message is clear and explains the purpose of the changes. It would be helpful to also update the README.md to reflect this new validation step in the installation process.

Specific Comments:

  • Missing Kit File vs. Missing Kit Directory: The code currently checks if the path exists with -e, which works for both files and directories. The language in the warning message currently says "kit files/directories". It might be more precise to determine if the missing path is expected to be a file vs a directory, and adjust the warning language accordingly. But this might add significant complexity so it may be best to leave it as is.
  • Error Handling with yq: The code includes 2>/dev/null when calling yq. This suppresses errors, which is generally good for preventing noisy output. However, it also means that if yq itself is not installed or has a problem, the script will silently assume "none" for the upload_extra value. Consider adding a check to ensure yq is installed before running the loop and provide a more informative error if it is not.
  • Array Handling: The code handles both string and array values for upload_extra. This is good.
  • Variable Naming: The variable name missing_kits is good, but template and path inside the loop could be more descriptive (e.g., template_name, kit_path).

Suggestions:

  1. Add a check for yq installation: Include a check to verify that yq is installed and provide a warning if it isn't.
  2. Update README: Document the new validation step in the README.md file.

Revised Code (incorporating suggestion 1):

--- a/bin/install.sh
+++ b/bin/install.sh
@@ -212,6 +212,15 @@
 echo ""
 echo "Validating kit directories..."
 
+# Check if yq is installed
+if ! command -v yq &> /dev/null; then
+    echo ""
+    echo "WARNING: yq is not installed. Kit directory validation will be skipped."
+    echo "Please install yq (version 2.10.0) to enable kit validation."
+    echo ""
+    exit 0 # Skip the rest of the validation
+fi
+
 missing_kits=()
 config_dir=$(readlink -f "config")
 

Voting Directive:

Vote: +1

Vote: +1

PullHero

@github-actions
Copy link

PullHero Review

Provider: generativelanguage.googleapis.com Model: gemini-2.0-flash

Okay, I've reviewed the changes to bin/install.sh. The primary goal of these changes is to validate the existence of "kit" files/directories referenced in the Zathras configuration templates (config/*_template.yml). This validation aims to proactively warn users about missing dependencies before running benchmarks, which can prevent unexpected failures.

Here's a breakdown of my analysis:

Positive Aspects:

  • Proactive Error Detection: The code addresses a real-world problem: missing kit files leading to benchmark failures. By validating these files during installation, users receive early warnings, improving their experience.
  • Clear Warning Message: The warning message is well-formatted and informative, clearly stating the missing files, the affected templates, and potential consequences. It also guides users on how to resolve the issues.
  • Handles both String and Array types for upload_extra: The code correctly handles both string (space-separated) and array formats for the upload_extra field, making it flexible and robust.
  • Uses yq for YAML parsing: Using yq is appropriate for parsing YAML files in a shell script.

Potential Concerns and Suggestions:

  • Dependency on yq: The script relies on yq. While yq is listed as a requirement in the README.md, it might be beneficial to add a check within the script to ensure yq is installed before attempting to use it. If it's not, the script could print an error message and exit or suggest installation instructions. This would improve the script's robustness.

  • Error Handling with yq: The code includes 2>/dev/null when calling yq to suppress errors. While this prevents error messages from cluttering the output, it also hides potential issues with yq itself (e.g., syntax errors in the template files). Consider logging these errors to a separate file for debugging purposes: yq -r ... 2> yq_errors.log.

  • Code Duplication: The logic for checking if a path exists is duplicated within the array and string processing sections. Consider refactoring this into a separate function to improve readability and maintainability.

  • Readability: The logic for extracting the template name and path from the entry variable could be made more readable by using more descriptive variable names.

  • Robustness with spaces in paths: The splitting of paths on spaces might cause issues if the paths themselves contain spaces. Although unusual, it's still possible. A more robust solution might involve using yq to directly extract the array/string elements into separate variables without relying on IFS. However, this would likely require more complex yq expressions.

Refactored Code Snippet (Illustrative):

# Check if upload_extra is a valid path
check_path_exists() {
  local template_name="$1"
  local path="$2"

  if [[ "$path" != "none" ]] && [[ -n "$path" ]]; then
    if [[ ! -e "$path" ]]; then
      missing_kits+=("$template_name:$path")
    fi
  fi
}

# Process upload_extra value
process_upload_extra() {
  local template_file="$1"
  local template_name="$2"
  local upload_extra="$3"
  local is_array

  is_array=$(yq -r '.upload_extra | type' "$template_file" 2>/dev/null || echo "null")

  if [[ "$is_array" == "array" ]]; then
    # It's an array, process each element
    while IFS= read -r path; do
      check_path_exists "$template_name" "$path"
    done < <(yq -r '.upload_extra[]' "$template_file" 2>/dev/null)
  else
    # It's a string, split by spaces
    IFS=' ' read -ra paths <<< "$upload_extra"
    for path in "${paths[@]}"; do
      check_path_exists "$template_name" "$path"
    done
  fi
}

for template_file in config/*_template.yml; do
    # Skip if no files match the pattern
    [ -e "$template_file" ] || continue

    template_name=$(basename "$template_file")

    # Extract upload_extra value using yq
    upload_extra=$(yq -r '.upload_extra // "none"'

**Vote**: 0

**[PullHero](https://github.com/pullhero/)**

Copy link
Contributor

@grdumas grdumas left a comment

Choose a reason for hiding this comment

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

LGTM

@sayalibhavsar sayalibhavsar merged commit 0afba88 into main Feb 24, 2026
16 of 28 checks passed
Copy link
Contributor

@dvalinrh dvalinrh left a comment

Choose a reason for hiding this comment

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

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

group_review_lgtm Indicates approval after a group review meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zathras should warn if /home/uploads directory is missing

3 participants