flipped-aurora/gin-vue-admin · error

技能不存在

Error message

技能不存在

What it means

SkillsService.Delete resolves the skill directory and stats it; when os.Stat returns an IsNotExist error the skill directory does not exist on disk, so the service returns this error instead of attempting RemoveAll on a missing path.

Source

Thrown at server/service/system/sys_skills.go:180

	}
	return nil
}

func (s *SkillsService) Delete(_ context.Context, req request.SkillDeleteRequest) error {
	if strings.TrimSpace(req.Tool) == "" {
		return errors.New("工具类型不能为空")
	}
	if !isSafeName(req.Skill) {
		return errors.New("技能名称不合法")
	}
	skillDir, err := s.skillDir(req.Tool, req.Skill)
	if err != nil {
		return err
	}
	info, err := os.Stat(skillDir)
	if err != nil {
		if os.IsNotExist(err) {
			return errors.New("技能不存在")
		}
		return err
	}
	if !info.IsDir() {
		return errors.New("技能目录异常")
	}
	return os.RemoveAll(skillDir)
}

func (s *SkillsService) Package(_ context.Context, req request.SkillPackageRequest) (string, []byte, error) {
	if strings.TrimSpace(req.Tool) == "" {
		return "", nil, errors.New("工具类型不能为空")
	}
	if !isSafeName(req.Skill) {
		return "", nil, errors.New("技能名称不合法")
	}

	skillDir, err := s.skillDir(req.Tool, req.Skill)

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Refresh the skill list and confirm the skill still exists before deleting.
  2. Treat this error as idempotent success if the goal is just 'skill gone' (ignore or log it).
  3. Check the skills root path for the tool to confirm the directory name spelling/case.

Example fix

// before: blind delete -> error on second call
err := skillsService.Delete(ctx, req)
// after: tolerate already-deleted
if err != nil && err.Error() == "技能不存在" {
    err = nil // already removed
}
Defensive patterns

Strategy: try-catch

Validate before calling

const list = await api.listSkills(req.Tool)
if (!list.some(s => s.name === req.Skill)) {
  // skip delete: already gone
  return
}
await api.deleteSkill(req)

Try / catch

err := skillsService.Delete(ctx, req)
if err != nil && err.Error() == "技能不存在" {
    err = nil // idempotent delete
}

Prevention

When it happens

Trigger: Calling Delete for a (tool, skill) pair whose directory was already removed, never created, or whose name differs in case/spelling from the on-disk directory.

Common situations: Double-clicking delete and submitting twice; skills directory deleted manually or by a git checkout/sync; stale frontend list referencing a renamed skill.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/64173aaed51e7aec. Report an issue: GitHub.