{"record":{"id":"aabfa526b9b0d580","repo":"JuliusBrussee/caveman","slug":"invalid-since-q-want-rfc3339-w","errorCode":null,"errorMessage":"invalid --since %q (want RFC3339): %w","messagePattern":"invalid --since %q \\(want RFC3339\\): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/internal/store/store.go","lineNumber":844,"sourceCode":"\tout.Basis = \"inferred\"\n\treturn out, nil\n}\n\n// ObserveSummarySince returns the compact observe-estimate object, optionally\n// filtered to rows at or after an RFC3339 instant (the wrap session start). It\n// mixes the observe-only would-have-saved numbers with the real compression cut so\n// one call serves both the \"would have cut\" (observe) and \"cut\" (compress) session\n// lines. Everything it reports is `inferred`; savings_usd is whatever was truly\n// booked (0 in observe mode), and would_save_usd stays nil unless a priced row\n// produced one.\nfunc (s *Store) ObserveSummarySince(since string) (ObserveSummary, error) {\n\tout := ObserveSummary{Basis: \"inferred\", TokenAccounting: map[string]int64{}}\n\twhere := \"\"\n\tvar args []any\n\tif trimmed := strings.TrimSpace(since); trimmed != \"\" {\n\t\tt, err := time.Parse(time.RFC3339, trimmed)\n\t\tif err != nil {\n\t\t\treturn out, fmt.Errorf(\"invalid --since %q (want RFC3339): %w\", trimmed, err)\n\t\t}\n\t\twhere = \" WHERE ts >= ?\"\n\t\targs = append(args, t.UTC().Format(storeTSLayout))\n\t}\n\tvar usdCount int64\n\tvar usdSum float64\n\trow := s.db.QueryRow(`SELECT COUNT(*), COALESCE(SUM(input_tokens),0), COALESCE(SUM(would_save_tokens),0),\n\t\tCOALESCE(SUM(compression_tokens_before),0), COALESCE(SUM(compression_tokens_after),0),\n\t\tCOALESCE(SUM(compression_tokens_before - compression_tokens_after),0),\n\t\tCOALESCE(SUM(savings_usd),0), COUNT(would_save_usd), COALESCE(SUM(would_save_usd),0),\n\t\tCOALESCE(SUM(cached_input_tokens),0), COALESCE(SUM(cache_creation_input_tokens),0),\n\t\tCOALESCE(SUM(CASE WHEN cache_bust <> 0 THEN 1 ELSE 0 END),0),\n\t\tCOALESCE(SUM(CASE WHEN compression_eligible <> 0 THEN 1 ELSE 0 END),0)\n\t\tFROM requests`+where, args...)\n\tif err := row.Scan(&out.Spans, &out.TokensIn, &out.WouldSaveTokens,\n\t\t&out.CompressionTokensBefore, &out.CompressionTokensAfter, &out.CompressionTokensSaved,\n\t\t&out.SavingsUSD, &usdCount, &usdSum,\n\t\t&out.CachedInputTokens, &out.CacheCreationInputTokens,","sourceCodeStart":826,"sourceCodeEnd":862,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/internal/store/store.go#L826-L862","documentation":"ObserveSummarySince accepts an optional RFC3339 timestamp; if the provided string is non-empty and fails time.Parse(time.RFC3339, ...), the summary is not computed and this error reports the offending value. The --since flag value must be a strict RFC3339 timestamp.","triggerScenarios":"Calling Store.ObserveSummarySince(\"2024/01/15\") or any non-RFC3339 string — missing timezone (e.g. \"2024-01-15 10:00:00\"), using slashes, or passing 'yesterday'.","commonSituations":"Users type --since with a human-friendly date format, omit the Z/offset, or shell-quote issues drop part of the timestamp.","solutions":["Use full RFC3339 form: 2024-01-15T10:00:00Z (include the T and timezone offset).","If parsing user input, accept flexible formats and reformat to RFC3339 before calling.","Omit the argument entirely (empty string) for an all-time summary.","Pre-validate with time.Parse(time.RFC3339, v) in the CLI layer to give a friendlier message."],"exampleFix":"// before\nsummary, err := store.ObserveSummarySince(\"2024-01-15 10:00:00\")\n// after\nsummary, err := store.ObserveSummarySince(\"2024-01-15T10:00:00Z\")","handlingStrategy":"validation","validationCode":"func validSince(v string) bool {\n    v = strings.TrimSpace(v)\n    if v == \"\" { return true }\n    _, err := time.Parse(time.RFC3339, v)\n    return err == nil\n}","typeGuard":null,"tryCatchPattern":"summary, err := store.ObserveSummarySince(since)\nif err != nil && strings.Contains(err.Error(), \"invalid --since\") {\n    return fmt.Errorf(\"--since must be RFC3339, e.g. 2024-01-15T10:00:00Z\")\n}","preventionTips":["Always include the T separator and timezone offset (Z or ±hh:mm).","Pre-validate --since in flag parsing with time.Parse(time.RFC3339, ...).","Provide an example timestamp in --help text."],"tags":["cli","timestamp","validation"],"backgroundTag":"invalid-date-format","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}