Fix labels field type: []string → []LabelInput

The queue-processor sends labels as an array of objects matching
TypeScript's CreateLabelInput interface, e.g.:

  labels: [{"name":"RSS"}]

The Go struct had this declared as []string, causing an unmarshal error
whenever an RSS feed job arrived:

  json: cannot unmarshal object into Go struct field JobData.labels of type string

Fix both JobData (incoming jobs) and savePageJobData (outgoing jobs) to
use []LabelInput{Name, Color, Description}, matching the TS types exactly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Aliaksei Karneyeu 2026-03-06 11:43:03 +01:00
parent ade0be223c
commit 95aafb7136

View file

@ -24,6 +24,14 @@ import (
"github.com/redis/go-redis/v9"
)
// LabelInput mirrors the TS CreateLabelInput interface.
// Labels are sent as objects (e.g. {"name":"RSS"}), not plain strings.
type LabelInput struct {
Name string `json:"name"`
Color *string `json:"color,omitempty"`
Description *string `json:"description,omitempty"`
}
// UserConfig mirrors the TS UserConfig interface.
type UserConfig struct {
ID string `json:"id"`
@ -31,13 +39,13 @@ type UserConfig struct {
Folder *string `json:"folder,omitempty"`
}
// JobData mirrors the TS JobData interface exactly.
// JobData mirrors the TS FetchContentJobData interface.
type JobData struct {
URL string `json:"url"`
UserID *string `json:"userId,omitempty"`
SaveRequestID string `json:"saveRequestId"`
State *string `json:"state,omitempty"`
Labels []string `json:"labels,omitempty"`
Labels []LabelInput `json:"labels,omitempty"`
Source *string `json:"source,omitempty"`
TaskID *string `json:"taskId,omitempty"`
Locale *string `json:"locale,omitempty"`
@ -52,21 +60,21 @@ type JobData struct {
// savePageJobData mirrors SavePageJobData from job.ts.
type savePageJobData struct {
UserID string `json:"userId"`
URL string `json:"url"`
FinalURL string `json:"finalUrl"`
ArticleSavingRequestID string `json:"articleSavingRequestId"`
State *string `json:"state,omitempty"`
Labels []string `json:"labels,omitempty"`
Source string `json:"source"`
Folder *string `json:"folder,omitempty"`
RSSFeedURL *string `json:"rssFeedUrl,omitempty"`
SavedAt *string `json:"savedAt,omitempty"`
PublishedAt *string `json:"publishedAt,omitempty"`
TaskID *string `json:"taskId,omitempty"`
Title string `json:"title,omitempty"`
ContentType string `json:"contentType,omitempty"`
CacheKey string `json:"cacheKey,omitempty"`
UserID string `json:"userId"`
URL string `json:"url"`
FinalURL string `json:"finalUrl"`
ArticleSavingRequestID string `json:"articleSavingRequestId"`
State *string `json:"state,omitempty"`
Labels []LabelInput `json:"labels,omitempty"`
Source string `json:"source"`
Folder *string `json:"folder,omitempty"`
RSSFeedURL *string `json:"rssFeedUrl,omitempty"`
SavedAt *string `json:"savedAt,omitempty"`
PublishedAt *string `json:"publishedAt,omitempty"`
TaskID *string `json:"taskId,omitempty"`
Title string `json:"title,omitempty"`
ContentType string `json:"contentType,omitempty"`
CacheKey string `json:"cacheKey,omitempty"`
}
const maxImportAttempts = 1