parseOptionalStringSliceField parses string-list fields that accept either a single string or an array. Empty strings are filtered out.
(value any, fieldName string)
| 184 | // parseOptionalStringSliceField parses string-list fields that accept either |
| 185 | // a single string or an array. Empty strings are filtered out. |
| 186 | func parseOptionalStringSliceField(value any, fieldName string) []string { |
| 187 | if singleValue, ok := value.(string); ok { |
| 188 | if singleValue == "" { |
| 189 | return nil |
| 190 | } |
| 191 | roleLog.Printf("Extracted single %s: %s", fieldName, singleValue) |
| 192 | return []string{singleValue} |
| 193 | } |
| 194 | |
| 195 | values := parseStringSliceAny(value, roleLog) |
| 196 | if len(values) == 0 { |
| 197 | roleLog.Printf("No valid %s found or unsupported type: %T", fieldName, value) |
| 198 | return nil |
| 199 | } |
| 200 | |
| 201 | result := make([]string, 0, len(values)) |
| 202 | for _, item := range values { |
| 203 | if item != "" { |
| 204 | result = append(result, item) |
| 205 | } |
| 206 | } |
| 207 | if len(result) == 0 { |
| 208 | return nil |
| 209 | } |
| 210 | |
| 211 | roleLog.Printf("Extracted %d %s: %v", len(result), fieldName, result) |
| 212 | return result |
| 213 | } |
| 214 | |
| 215 | // extractRateLimitConfig extracts the user-rate-limit config from frontmatter. |
| 216 | func (c *Compiler) extractRateLimitConfig(frontmatter map[string]any) *RateLimitConfig { |
no test coverage detected