pocketbase icon indicating copy to clipboard operation
pocketbase copied to clipboard

[list] can't unmarshal response, err parsing time

Open modpotato opened this issue 5 months ago • 0 comments

[list] can't unmarshal response, err parsing time "2024-08-29 04:31:03.914Z" as "2006-01-02T15:04:05Z07:00": cannot parse " 04:31:03.914Z" as "T"

full error: 2024/08/29 15:56:22 Application crashed: Error in handleArtists (Batch 1): error processing artist 000000001354226: failed to check for existing artist archives: [list] can't unmarshal response, err parsing time "2024-08-29 04:31:03.914Z" as "2006-01-02T15:04:05Z07:00": cannot parse " 04:31:03.914Z" as "T"

code snippet:

	existingArchives, err := artistArchiveCollection.List(pocketbase.ParamsList{
		Filters: fmt.Sprintf("artist_id = '%s' && created > '%s'", artistID, lastModified),
		Sort:    "-created",
		Size:    1,
	})
	if err != nil {
		return fmt.Errorf("failed to check for existing artist archives: %v", err)
	}

ive been trying to fix this for a few days now and my only guess is its this api..

other possibly related snippets:

lastModified, err := parseTime(artist["last_modified"].(string))
	...
func parseTime(timeStr string) (time.Time, error) {
	scLayout := "2006-01-02T15:04:05Z"
	adjustedLayout := "2006-01-02 15:04:05.999Z"

	// sc format
	t, err := time.Parse(scLayout, timeStr)
	if err == nil {
		// If successful, return the parsed time
		return t, nil
	}

	// adjusted sc format
	t, err = time.Parse(adjustedLayout, timeStr)
	if err == nil {
		return t, nil
	}

	// pb format
	t, err = time.Parse(time.RFC3339Nano, timeStr)
	if err == nil {
		return t, nil
	}

	return time.Time{}, fmt.Errorf("unable to parse time string: %s", timeStr)
}

if this is my fault im sorry i just dont know whats causing it anymore

modpotato avatar Aug 29 '24 20:08 modpotato