Skip to content

RTECO-1777 - Fix install & update's --version related issue - #528

Merged
udaykb2 merged 9 commits into
mainfrom
RTECO-1777-jf-skills-version-issue
Aug 19, 2026
Merged

RTECO-1777 - Fix install & update's --version related issue#528
udaykb2 merged 9 commits into
mainfrom
RTECO-1777-jf-skills-version-issue

Conversation

@udaykb2

@udaykb2 udaykb2 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor
  • All tests have passed. If this feature is not already covered by the tests, new tests have been added.
  • The pull request is targeting the master branch.
  • The code has been validated to compile successfully by running go vet ./....
  • The code has been formatted properly using go fmt ./....

Summary

Fix three critical issues in Agent skills and plugins version resolution:

  1. Panic in Non-TTY Environments: Prevented 'device not configured' panic in CI/CD by adding terminal detection before prompting
  2. Missing Versions: Switched from filtered Skills API to raw storage API, exposing all versions (346 instead of ~180), including rtaut/rtdev builds
  3. Ambiguous 404 Errors: Added error disambiguation to distinguish between missing repositories and missing skills/plugins

All fixes are applied at the source functions, so every downstream command (install, update, list, publish, delete) benefits universally.

Changes

Issue 1: Panic in Non-TTY Environments (CI/CD)

Problem: Commands crashed with 'device not configured' panic when stdin is not a terminal (CI/CD pipelines, Docker, piped scripts).

Solution:

  • Added isStdinTerminal() check in agent/common/interactive.go to detect terminal availability
  • Enhanced IsNonInteractive() to check stdin, stdout, and CI environment variable
  • Both SelectPackageVersion() and ResolveRepo() now check terminal status before prompting

Result: All commands fail gracefully with a user-friendly error instead of panicking in non-interactive environments.

Issue 2: Server-Side Filtering Excluded Versions

Problem: Skills API returned only ~180 versions (filtered server-side); 346 total versions existed. rtaut/rtdev builds were invisible.

Solution:

  • Changed ListVersions() in agent/skills/common/skills_api.go to query raw Artifactory storage API (FolderInfo) instead of filtered /api/v3/skills endpoint
  • Directly reads version directories from filesystem without server-side filtering

Result: All 346 skill versions now visible; rtaut and rtdev builds accessible via install/update commands.

Issue 3: Ambiguous 404 Errors

Problem: 404 errors didn't distinguish between missing repositories and missing skills/plugins, breaking automation and confusing users.

Solution:

  • Implemented IsHTTPNotFound() and DisambiguateFolderError() helpers in agent/common/versions.go
  • When skill/plugin lookup fails with 404, immediately probe for repository existence
  • Returns contextual error based on what's actually missing

Result: Clear error messages enable better debugging and automation.

Error Messages:

  • "repository 'my-repo' not found" — when repository doesn't exist
  • "skill 'my-skill' not found in repository 'my-repo'" — when skill/plugin is missing

Files Modified

  • agent/common/interactive.go — Terminal detection with mocking support
  • agent/common/select_version.go — Version selection safety check
  • agent/common/resolve_repo.go — Repo resolution safety check
  • agent/common/versions.go — HTTP status code parsing and 404 disambiguation logic
  • agent/skills/common/skills_api.go — Raw storage API query, error disambiguation
  • agent/skills/common/skills_util.go — Updated to use new ListVersions behavior
  • agent/plugins/common/versions.go — Error disambiguation for plugins

Testing

TTY Panic Fix

# Should fail gracefully, not panic
echo "test" | jf skills install rtaut

# Should work without panic in CI
CI=true jf skills update

- [x] All [tests](https://github.com/jfrog/jfrog-cli-core#tests) passed. If this feature is not already covered by the tests, I added new tests.
- [x] All [static analysis checks](https://github.com/jfrog/jfrog-cli-core/actions/workflows/analysis.yml) passed.
- [x] Appropriate label is added to auto generate release notes.
- [x] I used gofmt for formatting the code before submitting the pull request.
- [x] PR description is clear and concise, and it includes the proposed solution/fix.
-----


<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Bug Fixes**
  - Improved error messages when repositories, plugins, skills, or versions are missing.
  - Version listings now validate inputs and correctly distinguish missing repositories from missing content.
  - Improved version checks for skills and plugins.

- **User Experience**
  - Improved detection of interactive versus non-interactive terminal sessions, including CI environments.

- **Tests**
  - Expanded coverage for repository and content-not-found scenarios and terminal detection behavior.

udaykb2 and others added 2 commits August 5, 2026 16:26
Issues fixed:

1. Panic in non-TTY environments (CI/CD)
   - Added hasStdinTTY() safety check before calling go-prompt
   - Prevents 'device not configured' panic when stdin is not a terminal
   - Affects: select_version.go, resolve_repo.go
   - Impact: All install/update/list/publish/delete commands now fail gracefully

2. Server-side filtering excluded rtaut/rtdev versions
   - Changed ListVersions() to use raw storage API (FolderInfo) instead of filtered Skills API
   - Skills API returned only ~180 versions; now all 346 versions accessible
   - Affects: skills_api.go, skills_util.go
   - Impact: rtaut and rtdev builds now visible and installable

3. Ambiguous 404 errors - couldn't distinguish repo vs skill/plugin missing
   - Added disambiguation logic: check repo existence when skill/plugin lookup fails
   - Now returns specific errors:
     * 'repository X not found' when repo doesn't exist
     * 'skill/plugin X not found in repository Y' when skill/plugin is missing
   - Affects: skills_api.go, plugins/common/versions.go
   - Impact: Clear error messages for debugging and automation

All fixes applied at source functions (ListVersions, listPluginVersions, SelectPackageVersion,
ResolveRepo) so every caller benefits universally. No changes needed in individual command
implementations (install, update, list, publish, delete).
Issues fixed:

1. Server-side filtering excluded rtaut/rtdev versions
   - Changed ListVersions() to use raw storage API (FolderInfo) instead of filtered Skills API
   - Skills API returned only ~180 versions; now all 346 versions accessible
   - Affects: skills_api.go, skills_util.go
   - Impact: rtaut and rtdev builds now visible and installable

2. Ambiguous 404 errors - couldn't distinguish repo vs skill/plugin missing
   - Added disambiguation logic: check repo existence when skill/plugin lookup fails
   - Now returns specific errors:
     * 'repository X not found' when repo doesn't exist
     * 'skill/plugin X not found in repository Y' when skill/plugin is missing
   - Affects: skills_api.go, plugins/common/versions.go
   - Impact: Clear error messages for debugging and automation

Note: Removed redundant TTY check. IsNonInteractive() already handles TTY detection
properly, so adding hasStdinTTY() was unnecessary. Tests confirm it works as expected.

All fixes applied at source functions (ListVersions, listPluginVersions) so every
caller benefits universally. No changes needed in individual command implementations.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Version listing now validates inputs, reads storage folders, and distinguishes missing repositories from missing plugins or skills. Interactive detection now checks both standard input and output terminal status, with expanded test coverage.

Changes

Version resolution

Layer / File(s) Summary
Folder error disambiguation
agent/common/versions.go, agent/common/versions_test.go
Adds shared handling that probes repository existence after a folder 404 and returns repository-specific or folder-specific errors.
Plugin version not-found handling
agent/plugins/common/versions.go
Trims and validates inputs, centralizes 404 disambiguation, and wraps listing failures.
Skill version listing and existence checks
agent/skills/common/skills_api.go, agent/skills/common/skills_util.go
Lists skill versions from raw storage folders, validates inputs, distinguishes 404 cases, and checks version existence through listed versions.

Interactive detection

Layer / File(s) Summary
Non-interactive terminal detection
agent/common/interactive.go, agent/common/interactive_test.go, agent/plugins/commands/publish/publish_test.go
Adds mockable stdin terminal detection. IsNonInteractive checks CI, stdout, and stdin terminal status. Tests cover terminal combinations and restore detector state.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: itsmeleela, agrasth

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: fixing version-related issues in install and update commands.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch RTECO-1777-jf-skills-version-issue

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@agent/common/select_version.go`:
- Around line 23-32: Replace the os.ModeCharDevice test in hasStdinTTY with a
real terminal-specific TTY check, preserving false on stat/check errors so
non-interactive stdin cannot reach go-prompt. Apply the same corrected check at
agent/common/select_version.go line 42 and agent/common/resolve_repo.go line 52;
update agent/common/interactive.go only if it contains the equivalent stdin
check.

In `@agent/plugins/common/versions.go`:
- Around line 36-42: Propagate non-404 errors from the repository probe instead
of reporting missing resources. In agent/plugins/common/versions.go lines 36-42,
update the FolderInfo handling to return or wrap repoErr for non-404 failures,
and only return ErrPluginNotFoundInRepo after a successful probe; apply the
equivalent change to the skill-not-found flow in
agent/skills/common/skills_api.go lines 60-65, preserving the existing 404
behavior.

In `@agent/skills/common/skills_api.go`:
- Around line 42-55: Add a trimmed slug validation in ListVersions before
CreateServiceManager, returning an appropriate error when the skill name is
empty. Preserve the existing repository validation and ensure the storage lookup
only runs with a non-empty skill slug.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3ce3eaf3-dfae-41fd-ad64-1ee67cc0dff3

📥 Commits

Reviewing files that changed from the base of the PR and between 1a5e6a2 and 9613a60.

📒 Files selected for processing (5)
  • agent/common/resolve_repo.go
  • agent/common/select_version.go
  • agent/plugins/common/versions.go
  • agent/skills/common/skills_api.go
  • agent/skills/common/skills_util.go

Comment thread agent/common/select_version.go Outdated
Comment thread agent/plugins/common/versions.go Outdated
Comment thread agent/skills/common/skills_api.go
Fixes from CodeRabbit PR #528 review:

1. Input Validation (skills_api.go, plugins/versions.go)
   - Added trimmed slug validation before API calls
   - Return error when skill/plugin name is empty
   - Only query storage with non-empty skill/plugin slug

2. Error Propagation (skills_api.go, plugins/versions.go)
   - Non-404 errors from repo probe now propagated with %w wrapping
   - Preserves error chain so callers can inspect failures
   - Distinguishes auth/network errors from not-found errors

3. Improved Comments (skills_api.go, plugins/versions.go)
   - Comments now explain WHY (business logic) not just WHAT
   - Better guidance for users troubleshooting missing resources
   - Align with Go Knowledge Base Section 17 (Comments)

4. Better Error Messages
   - Lowercase, no punctuation (Go style)
   - Include original error context with %w wrapping
   - Clear distinction: repo-missing vs resource-missing

Knowledge Base Compliance (https://go.dev/wiki/CodeReviewComments):
- ✅ Section 11 (Error Handling): All errors propagated or handled
- ✅ Section 17 (Comments): Explain non-obvious logic and why
- ✅ Section 21.5 (Error Handling Review): No silent failures
- ✅ Security: No secrets logged, input validated

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@udaykb2 udaykb2 added the bug Something isn't working label Aug 5, 2026
…olution

When jf skills update/install --version <x> fails to resolve an exact version
and stdin is not a terminal (CI/CD, pipes), go-prompt's NewStandardInputParser()
panics with 'device not configured' instead of returning a clean error.

Both SelectPackageVersion and ResolveRepo now check term.IsTerminal(stdin.Fd())
before calling go-prompt. On non-TTY, the same clean error message is returned
that --quiet already produces.

- Added golang.org/x/term import (already available: v0.45.0)
- Used term.IsTerminal() as more reliable terminal check than os.Stdin.Stat()
- Combined with existing IsNonInteractive() for defense-in-depth

Install and update commands now fail gracefully in non-interactive shells
instead of crashing.

Co-authored-by: Cursor <cursoragent@cursor.com>
@udaykb2
udaykb2 force-pushed the RTECO-1777-jf-skills-version-issue branch from dfc79e4 to badf634 Compare August 5, 2026 13:20

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
@.worktrees/task-RTECO-1648/task/RTECO-1648/rteco-1648-jf-agent-apm-implementation-document:
- Line 1: Update buildSourcesLine and the surrounding setup/command flow to
validate serverDetails.GetArtifactoryUrl() before credentials are appended or
the APT source is generated. Reject non-HTTPS URLs by default, allowing HTTP
only for an explicitly recognized local test endpoint, and preserve source
generation only after validation succeeds.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: de3e855d-cf52-4c57-9392-d3c9f3e28319

📥 Commits

Reviewing files that changed from the base of the PR and between 9613a60 and dfc79e4.

📒 Files selected for processing (6)
  • .worktrees/task-RTECO-1648/task/RTECO-1648/rteco-1648-jf-agent-apm-implementation-document
  • .worktrees/task-RTFACT-31140/task/RTFACT-31140/gradle-buildsrc-support
  • agent/common/interactive.go
  • agent/plugins/common/versions.go
  • agent/skills/common/skills_api.go
  • artifactory/commands/testdata/jfrog-cli.conf.v6
🚧 Files skipped from review as they are similar to previous changes (2)
  • agent/skills/common/skills_api.go
  • agent/plugins/common/versions.go

Comment thread agent/common/interactive.go Outdated
Comment thread agent/skills/common/skills_api.go
Comment thread agent/plugins/common/versions.go
@udaykb2
udaykb2 marked this pull request as draft August 6, 2026 08:31
… logic

- Update IsNonInteractive to use log.IsStdOutTerminal from jfrog-cli-core
- Extract duplicate 404-disambiguation logic into a shared DisambiguateFolderError helper
- Add comprehensive unit tests for DisambiguateFolderError in versions_test.go

Co-authored-by: Cursor <cursoragent@cursor.com>
@udaykb2 udaykb2 changed the title RTECO-1777 - Fix install & update related issue in agent skills RTECO-1777 - Fix install & update's --version related issue Aug 10, 2026
- Test IsNonInteractive with CI env vars
- Test IsNonInteractive when stdout is terminal vs non-terminal using log.SetIsTerminalFlagsWithCallback
- Test IsNonInteractive with piped stdin

Co-authored-by: Cursor <cursoragent@cursor.com>
@udaykb2
udaykb2 marked this pull request as ready for review August 10, 2026 10:15
@udaykb2 udaykb2 added the safe to test Approve running integration tests on a pull request label Aug 10, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Aug 10, 2026
@udaykb2 udaykb2 added the safe to test Approve running integration tests on a pull request label Aug 18, 2026
@github-actions github-actions Bot removed the safe to test Approve running integration tests on a pull request label Aug 18, 2026
@bhanurp
bhanurp self-requested a review August 18, 2026 10:23
@udaykb2
udaykb2 merged commit 20a55dd into main Aug 19, 2026
181 of 185 checks passed
@udaykb2
udaykb2 deleted the RTECO-1777-jf-skills-version-issue branch August 19, 2026 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants