feat(api): return skill labels from the skill listing endpoints on request - #730
Open
FenjuFu wants to merge 1 commit into
Open
feat(api): return skill labels from the skill listing endpoints on request#730FenjuFu wants to merge 1 commit into
FenjuFu wants to merge 1 commit into
Conversation
…quest
Skill labels were reachable only one skill at a time, through
/api/{v1,web}/skills/{namespace}/{slug}/labels, so a client rendering a list had
to issue a follow-up request per row.
Add includeLabels=true to GET /api/v1/skills and GET /api/web/skills. The labels
array is populated only when the parameter is set and left out of the payload
otherwise, so existing responses are byte-identical.
Labels for the whole page are resolved by SkillLabelProjectionService in three
queries — assignments, definitions, translations — rather than three per skill.
Closes #710
Signed-off-by: FenjuFu <fufenjupku@gmail.com>
FenjuFu
force-pushed
the
feat/skills-list-labels
branch
2 times, most recently
from
August 19, 2026 07:35
24af499 to
3329900
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /api/v1/skillsandGET /api/web/skillsacceptincludeLabels=trueand return each skill's labels inline./api/{v1,web}/skills/{namespace}/{slug}/labels, so a client rendering a list had to issue a follow-up request per row.{ "items": [ { "slug": "global/demo-skill", "displayName": "Demo Skill", "labels": [ { "slug": "audited", "type": "PRIVILEGED", "displayName": "Audited" }, { "slug": "automation", "type": "RECOMMENDED", "displayName": "Automation" } ] } ], "nextCursor": null }The issue named
/api/v1/skillsfirst and/api/web/skillsas the alternative, so both surfaces take the parameter. The payload shape is the existingSkillLabelDto(slug,type,displayName), same as the per-skill labels endpoint, with the display name localized throughLabelLocalizationServiceexactly as it is there.The default response does not change
labelsisnullunless the caller opts in, and both records carry@JsonInclude(NON_NULL)on that component only — not on the record — so no other nullable field starts being dropped. WithoutincludeLabels, responses are byte-identical to today, which matters for/api/v1/skills: it is the ClawHub compatibility surface with legacy clients on it.SkillSummaryResponseandClawHubSkillListResponse.SkillListItemeach keep a constructor at the previous arity that delegates withnull, so the seven existing construction sites are untouched.One batch, not one per row
Naively reusing the per-skill path would issue three queries per row — 75 for a default page of 25.
SkillLabelProjectionServiceresolves the whole page in three: assignments (findBySkillIdIn), definitions, translations. The unit test asserts that arity directly withverify(..., times(1)), so a regression to N+1 fails the build rather than quietly slowing the endpoint down.Validation
I could not run
mvn test— no JDK is available on the machine this was written on, so CI is the first real execution. Tests are included and I would ask a reviewer to weight CI over my checklist here:SkillLabelProjectionServiceTest— per-skill grouping, thetype-then-slugordering, assignments whose definition is missing, empty/null pages touching no repository, and the three-query batch arity.SkillSearchControllerTest—labelsabsent by default, populated withincludeLabels=true, and an empty array for a skill that has none.ClawHubCompatAppServiceTest— the same two cases on the/api/v1/skillscompatibility surface.Risk
includeLabelssee no change.skill_labeland the label definition tables are read as they already are.Notes
SkillLabelAppService.toDtosnow overlaps withSkillLabelProjectionService.toDto. Folding the former into the projection service would mean changingSkillLabelAppService's constructor, which I left alone to keep this diff to the feature; worth doing as a separate cleanup.