Skip to content

[Bug]: POST /api/skills/sync reports success when the public skills repository cannot be fetched #5933

Closed

Description

@enyst

I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.

Is there an existing issue for the same bug?

  • I have searched existing issues and this is not a duplicate.

Bug Description

POST /api/skills/sync forces a refresh of the cached public skills repository (OpenHands/extensions, or EXTENSIONS_REF). When the repository is already cloned and the fetch from its origin fails (offline, GitHub unreachable, origin moved), the endpoint still answers 200 {"status": "success", "message": "Skills repository synced successfully"}. Nothing was synced: the server keeps serving the stale clone. SyncResponse already has an error status for this case, but it is only reached when there is no clone at all.

Expected Behavior

When the fetch of the public skills repository fails, POST /api/skills/sync answers 200 {"status": "error", ...} with a message saying the sync failed. The existing clone stays on disk and keeps being used by skill loading (offline use is unchanged); only the sync report changes. A successful fetch still reports success, and a pinned tag/commit that is already present locally (no fetch needed) still reports success.

Actual Behavior

200 {"status": "success", "message": "Skills repository synced successfully"}, while the server log shows Failed to fetch updates: ... Using cached version.

Steps to Reproduce

  1. In a checkout of main: uv sync, then SESSION_API_KEY=dev-key OH_PERSISTENCE_DIR=$(mktemp -d) uv run python -m openhands.agent_server --host 127.0.0.1 --port 8000.
  2. Call curl -s -X POST -H 'X-Session-API-Key: dev-key' http://127.0.0.1:8000/api/skills/sync once while online, so $OH_PERSISTENCE_DIR/cache/skills/public-skills is cloned (status: success).
  3. Make the origin unreachable, e.g. git -C "$OH_PERSISTENCE_DIR/cache/skills/public-skills" remote set-url origin /nonexistent/repo (or disconnect the network).
  4. Call the sync again: it answers {"status": "success", "message": "Skills repository synced successfully"}.

With the verify-agent-server skill (#5621): control-agent-server map run --file F25 --only F25.sync-offline --fresh reports the known-bug bullet as an expected failure while the bug lasts.

Acceptance Criteria

  • POST /api/skills/sync reports status: error when the existing clone of the public skills repository cannot be fetched (or the requested ref cannot be checked out after the fetch).
  • The stale clone is kept and is still used by skill loading (load_public_skills, the marketplace and plugin catalog), which keep their current fall-back-to-cache behaviour.
  • A successful fetch, and a pinned ref already present locally, still report status: success.
  • A unit test covers a sync against an existing clone whose origin is unreachable.
  • The map bullet F25.sync-offline passes with its # bug marker removed.

Installation Method

uv sync in a checkout of main

Version

main at 6e7a853

Additional Context

Root cause:

  • sync_public_skills (openhands-agent-server/openhands/agent_server/skills_service.py:473-479) calls update_skills_repository and treats any returned path as success.
  • update_skills_repository (openhands-sdk/openhands/sdk/skills/utils.py:590-609) delegates to try_cached_clone_or_update(..., update=True), whose _update_repository (openhands-sdk/openhands/sdk/git/cached_repo.py:371) returns silently after _try_fetch (cached_repo.py:391-398) logs Failed to fetch updates: ... Using cached version. The repository path is then returned as if it were updated.
  • The router (openhands-agent-server/openhands/agent_server/skills_router.py:322-326) maps success=False to status: error, so only the service result needs to change.

The fall-back-to-cache behaviour is right for the other callers of update_skills_repository (loading public skills, the marketplace catalog, the plugins catalog); only the explicit sync should report it.

Found by the first full agentic run of verify-agent-server; tracked in #5653.


OpenHands AI triage

The following comments and acceptance criteria were added by the OpenHands AI agent.

Triage

Confirmed against main (6e7a853). sync_public_skills (openhands-agent-server/openhands/agent_server/skills_service.py:462) treats any non-None path from update_skills_repository as success, but _update_repository (openhands-sdk/openhands/sdk/git/cached_repo.py:371) returns the cached path after _try_fetch swallows a fetch failure, so an explicit sync reports success while the stale clone is served. The router already maps success=False to status: error (skills_router.py:322), and SyncResponse.status is already Literal["success","error"], so the response shape does not change.

Bounded scope: make the explicit sync distinguish "the cached clone was refreshed" from "the cached clone was served stale", and report status: error in the latter case (fetch failure, or the requested ref not checkable after a fetch).

Explicit non-goals: do not change the fall-back-to-cache behaviour of the other update_skills_repository callers (load_public_skills, the marketplace catalog, the plugins catalog); do not change the HTTP status, the SyncResponse schema, or add request parameters; do not add retry/backoff; do not delete or move the stale clone.

Priority stays priority:low: the failure is a misleading status only, the recorded source is an agentic verify run rather than a user or production report, and there is a clear workaround (inspect the server log or the clone).

Acceptance Criteria

  • POST /api/skills/sync answers HTTP 200 with {"status": "error", ...} and a message stating the sync failed when the public skills clone exists but its origin cannot be fetched.
  • POST /api/skills/sync answers status: error when the fetch succeeds but the requested ref (PUBLIC_SKILLS_REF / EXTENSIONS_REF) cannot be checked out.
  • POST /api/skills/sync still answers status: success after a successful fetch, on a first-time clone, and when a pinned tag/commit ref is already present locally so no fetch is needed.
  • After a failed sync, the existing clone stays on disk and POST /api/skills with load_public: true, GET /api/skills/marketplace, and the plugins catalog still serve skills from that stale clone (fall-back-to-cache unchanged).
  • The response contract is unchanged: SyncResponse keeps status: Literal["success","error"] plus message, the route still returns HTTP 200, and the other update_skills_repository callers keep their current silent fall-back behaviour.
  • A failed sync does not clear the in-memory public-skills cache, while a successful sync still clears it.
  • An automated test under tests/agent_server/ covers a sync against an existing clone whose origin is unreachable and asserts the failure result; the existing router test confirms the failure maps to status: error.
  • The verify-agent-server map bullet F25.sync-offline passes with its # bug marker removed in .agents/skills/verify-agent-server/references/feature-map/F25-skills.md.

Activity

  1. added
    bug
    on Oct 14, 2026
  2. added
    ready-for-dev
    on Oct 14, 2026
  3. enyst commented on Oct 14, 2026

    @enyst
    MemberAuthor

    I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.

    Fix proposed in #5944.

    A maintainer needs to decide what a failed sync means while a stale clone exists. Implemented: POST /api/skills/sync answers {"status": "error", "message": "Failed to sync skills repository"} and the stale clone is kept on disk, so load_public_skills and the marketplace/plugins catalogs keep serving it offline as today. The sync is an explicit refresh request, so its report should say whether the refresh happened, while deleting or hiding the cached copy would make an offline server lose its public skills. Alternatives: (a) a distinct status or a using_cached field on SyncResponse (an API shape change that the TS client would also need), or (b) keep success and only reword the message. The message text itself is unchanged.

    Mechanism: an opt-in strict flag on try_cached_clone_or_update / update_skills_repository, used only by the sync; every other caller keeps the fall-back-to-cache default. A pinned tag/SHA already present locally still skips the fetch and reports success. The map bullet F25.sync-offline is updated in the same PR (marker removed; xfail x2 on main, xpass x2 on the branch, then pass).


    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugready-for-dev

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions