Skip to content

Commit c957348

Browse files
huimiuCopilot
andcommitted
fix(skills): pre-check has_blob before download for clearer error
Skills created from inline JSON or SKILL.md have no downloadable package; the server returns an opaque 404 'does not have an associated package'. Pre-flight Get the skill so the download command can return a structured CodeSkillNoPackage validation error with an actionable suggestion. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 09a750b commit c957348

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

cli/azd/extensions/azure.ai.skills/internal/cmd/skill_download.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,26 @@ func (a *downloadAction) Run(ctx context.Context) error {
6969
return err
7070
}
7171

72+
// Pre-flight via Get so we can detect the "no associated package" case
73+
// before issuing the :download call. The service returns 404 with a
74+
// dedicated error code when the skill was created from inline JSON (or a
75+
// SKILL.md file) rather than a gzip package, but the message is opaque —
76+
// surfacing the HasBlob check up front gives the user a clearer answer.
77+
skill, err := skillCtx.client.Get(ctx, a.flags.name)
78+
if err != nil {
79+
return exterrors.ServiceFromAzure(err, exterrors.OpGetSkill)
80+
}
81+
if !skill.HasBlob {
82+
return exterrors.Validation(
83+
exterrors.CodeSkillNoPackage,
84+
fmt.Sprintf("skill %q has no downloadable package", a.flags.name),
85+
"only skills created from a `.tar.gz` / `.tgz` archive have a downloadable "+
86+
"package. Use `azd ai skill show <name>` to inspect metadata; "+
87+
"re-create with `azd ai skill create <name> --file <archive>.tar.gz --force` "+
88+
"if you want a downloadable copy.",
89+
)
90+
}
91+
7292
body, err := skillCtx.client.Download(ctx, a.flags.name)
7393
if err != nil {
7494
return exterrors.ServiceFromAzure(err, exterrors.OpDownloadSkill)

cli/azd/extensions/azure.ai.skills/internal/exterrors/codes.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const (
3232
CodeMissingForceFlag = "missing_force_flag"
3333
CodeSkillNotFound = "skill_not_found"
3434
CodeSkillAlreadyExists = "skill_already_exists"
35+
CodeSkillNoPackage = "skill_no_package"
3536
)
3637

3738
// Error codes for auth.

0 commit comments

Comments
 (0)