RTECO-1777 - Fix install & update's --version related issue - #528
Conversation
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>
📝 WalkthroughWalkthroughVersion 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. ChangesVersion resolution
Interactive detection
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (5)
agent/common/resolve_repo.goagent/common/select_version.goagent/plugins/common/versions.goagent/skills/common/skills_api.goagent/skills/common/skills_util.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>
…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>
dfc79e4 to
badf634
Compare
There was a problem hiding this comment.
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
📒 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-supportagent/common/interactive.goagent/plugins/common/versions.goagent/skills/common/skills_api.goartifactory/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
… 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>
- 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>
masterbranch.go vet ./....go fmt ./....Summary
Fix three critical issues in Agent skills and plugins version resolution:
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:
isStdinTerminal()check inagent/common/interactive.goto detect terminal availabilityIsNonInteractive()to check stdin, stdout, and CI environment variableSelectPackageVersion()andResolveRepo()now check terminal status before promptingResult: 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:
ListVersions()inagent/skills/common/skills_api.goto query raw Artifactory storage API (FolderInfo) instead of filtered/api/v3/skillsendpointResult: 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:
IsHTTPNotFound()andDisambiguateFolderError()helpers inagent/common/versions.goResult: 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 missingFiles Modified
agent/common/interactive.go— Terminal detection with mocking supportagent/common/select_version.go— Version selection safety checkagent/common/resolve_repo.go— Repo resolution safety checkagent/common/versions.go— HTTP status code parsing and 404 disambiguation logicagent/skills/common/skills_api.go— Raw storage API query, error disambiguationagent/skills/common/skills_util.go— Updated to use new ListVersions behavioragent/plugins/common/versions.go— Error disambiguation for pluginsTesting
TTY Panic Fix