Skip to content

Fix Nacos skill marketplace latest label resolution#1589

Open
lancefoever wants to merge 9 commits into
agentscope-ai:mainfrom
lancefoever:fix/nacos-skill-latest-label
Open

Fix Nacos skill marketplace latest label resolution#1589
lancefoever wants to merge 9 commits into
agentscope-ai:mainfrom
lancefoever:fix/nacos-skill-latest-label

Conversation

@lancefoever

Copy link
Copy Markdown

AgentScope-Java Version

main branch

Description

Background

When using the Builder Nacos marketplace, skill preview/install can fail while loading a skill version detail.

The previous implementation passed the label name LATEST directly as the version argument to getSkillVersionDetail(namespaceId, skillName, version). However, the Nacos skill version detail API expects the actual skill version value, not the label name.

This could produce a request equivalent to:

/nacos/v3/admin/ai/skills/version?skillName=<skillName>&namespaceId=<namespaceId>&version=LATEST

Nacos then returns an error similar to:

Skill version not found: <skillName>@LATEST

Purpose

This PR fixes Nacos-backed Builder marketplace preview/install by resolving the real skill version from the skill metadata labels before loading the skill version detail.

Changes Made

  • Load skill metadata through the Nacos maintainer client.
  • Resolve the actual skill version from the LATEST label in the skill metadata.
  • Use the resolved version value when calling getSkillVersionDetail(...).
  • Add validation so a clear error is raised if the LATEST label cannot be resolved.

How to Test

  1. Start a Nacos server with Skill Registry support.
  2. Create or publish a Nacos skill with a LATEST label pointing to an online skill version.
  3. Add the Nacos marketplace in Builder.
  4. Preview the Nacos skill from Builder.
  5. Install the skill into an agent.

Expected result:

  • Builder no longer requests skill details with version=LATEST.
  • Builder resolves the actual skill version from Nacos skill metadata.
  • Skill preview succeeds.
  • Skill installation succeeds.
  • The installed skill appears in the agent's skills list.

Local validation:

mvn -q -pl agentscope-examples/agents/agentscope-builder -am spotless:apply
mvn -q -pl agentscope-examples/agents/agentscope-builder -am -DskipTests compile

Checklist

Please check the following items before code is ready to be reviewed.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

@lancefoever lancefoever requested a review from a team June 4, 2026 02:36
@CLAassistant

CLAassistant commented Jun 4, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@lancefoever lancefoever force-pushed the fix/nacos-skill-latest-label branch from 5d30ed0 to d5a17cf Compare June 4, 2026 02:51

@AgentScopeJavaBot AgentScopeJavaBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 AI Review

This PR correctly identifies the root cause — Nacos's getSkillVersionDetail API expects an actual version string, not a label name — and routes the call through getSkillMeta first to resolve a real version from the labels map. The control flow, null/blank guards, and the clear IllegalStateException on unresolvable labels are all reasonable.

However, the fix as written likely will not work end-to-end against Nacos's standard publish flow. In Nacos (com.alibaba.nacos.ai.constant.AiResourceConstants) the canonical label key for the latest published version is "latest" (lowercase), set automatically by SkillOperationServiceImpl#publish(...) when updateLatestLabel=true. The PR reuses the existing LATEST_VERSION = "LATEST" (uppercase) constant as the lookup key into skillMeta.getLabels(), which will miss the canonical label and trip the new IllegalStateException for any skill published the normal way. The test steps in the PR description ("create a skill with a LATEST label") effectively work around the bug by asking the tester to set a non-standard label.

Secondary items: the class Javadoc still describes the old getSkillVersionDetail(..., "LATEST") behavior and should be refreshed; the constant LATEST_VERSION is now semantically a label key, not a version, so renaming it (e.g. to LATEST_LABEL) keeps intent clear.

@AgentScopeJavaBot AgentScopeJavaBot added bug Something isn't working area/examples agentscope-examples labels Jun 4, 2026

@AgentScopeJavaBot AgentScopeJavaBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

All previously raised review comments have been addressed.

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

Labels

area/examples agentscope-examples bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants