Skip to content

Commit 3b6cdaf

Browse files
fix: extract text-content for option name and iteration title in map path
The generic map decoding path for project field values treated 'name' (ProjectV2FieldOption) and 'title' (ProjectV2FieldIteration) as plain strings, but the GitHub API returns them as ProjectV2TextContent objects with raw/html fields. As a result, single-select option names and iteration titles could be returned empty when values reached the minimal converter as map[string]any instead of typed structs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1229510 commit 3b6cdaf

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

pkg/github/minimal_types.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,7 +1143,7 @@ func minimalProjectTextValue(value map[string]any) string {
11431143
}
11441144

11451145
func minimalProjectOptionFromMap(value map[string]any) (minimalProjectOptionValue, bool) {
1146-
name := stringFromMap(value, "name")
1146+
name := textContentStringFromMap(value, "name")
11471147
color := stringFromMap(value, "color")
11481148
if name == "" && color == "" {
11491149
return minimalProjectOptionValue{}, false
@@ -1163,12 +1163,25 @@ func minimalProjectIterationFromMap(value map[string]any) (minimalProjectIterati
11631163
}
11641164
return minimalProjectIterationValue{
11651165
ID: stringFromMap(value, "id"),
1166-
Title: stringFromMap(value, "title"),
1166+
Title: textContentStringFromMap(value, "title"),
11671167
StartDate: startDate,
11681168
Duration: duration,
11691169
}, true
11701170
}
11711171

1172+
// textContentStringFromMap returns a string for a field that may be either a
1173+
// plain string or a nested ProjectV2TextContent object (with raw/html/text
1174+
// fields), as returned for project option names and iteration titles.
1175+
func textContentStringFromMap(value map[string]any, key string) string {
1176+
if s := stringFromMap(value, key); s != "" {
1177+
return s
1178+
}
1179+
if nested, ok := value[key].(map[string]any); ok {
1180+
return minimalProjectTextValue(nested)
1181+
}
1182+
return ""
1183+
}
1184+
11721185
func minimalProjectPullRequestRefsFromArray(values []any) ([]minimalProjectPullRequestRef, bool) {
11731186
refs := make([]minimalProjectPullRequestRef, 0, len(values))
11741187
for _, value := range values {

0 commit comments

Comments
 (0)