Skip to content

fix: resolve labels field options using "label" key#6

Open
neptunix wants to merge 1 commit intotriptechtravel:mainfrom
neptunix:fix/labels-field-resolution
Open

fix: resolve labels field options using "label" key#6
neptunix wants to merge 1 commit intotriptechtravel:mainfrom
neptunix:fix/labels-field-resolution

Conversation

@neptunix
Copy link
Contributor

Summary

  • Labels-type custom field options use a "label" key in the ClickUp API response, while dropdown fields use "name". All option resolution code only checked "name", causing labels fields to fail with label "X" not found for field "Y" (available: (none)).
  • Added getOptionName() helper that checks "name" first, falling back to "label", and updated all call sites.

Fixes setting labels fields via --field "SF :: Team=Web" on task create and task edit, including comma-separated multi-labels like --field "SF :: Team=Web,Phoenix".

Root cause

The ClickUp API returns different key names for option display text depending on field type:

  • Dropdown (drop_down): {"name": "Feature", "id": "...", "orderindex": 0}
  • Labels (labels): {"label": "Web", "id": "...", "orderindex": 3}

The existing code in resolveLabelOptions, resolveDropdownOption, listOptionNames, formatDropdownValue, and formatLabelsValue all only checked opt["name"].

Changes

  • custom_fields.go: Added getOptionName(opt) that returns opt["name"] or opt["label"]
  • Updated 6 call sites to use getOptionName() instead of direct opt["name"] access

Test plan

  • All existing tests pass (go test ./...)
  • Manual: clickup task create --field "SF :: Team=Web" succeeds (was: label "Web" not found)
  • Manual: clickup task edit <id> --field "SF :: Team=Web,Phoenix" sets both labels
  • Manual: clickup task view <id> displays labels field values correctly
  • Manual: dropdown fields still work correctly after changes

🤖 Generated with Claude Code

The ClickUp API returns label-type custom field options with a "label"
key instead of "name" (which dropdown fields use). This caused all
labels field operations to fail with "available: (none)" because the
code only checked opt["name"].

Added getOptionName() helper that checks "name" first, falling back
to "label". Updated all call sites: resolveLabelOptions,
resolveDropdownOption, listOptionNames, formatDropdownValue, and
formatLabelsValue.

Fixes setting labels fields via --field "SF :: Team=Web" on both
task create and task edit, including comma-separated multi-labels.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant