inancgumus/learngo · error
record.domain cannot be empty|record.page cannot be empty|re
Error message
record.domain cannot be empty|record.page cannot be empty|record.visits cannot be negative|record.uniques cannot be negative
What it means
The v6 logly validate() checks Domain/Page emptiness and negative Visits/Uniques, returning a single error whose message is whichever rule failed. In v6 the caller (this error's combined message) aggregates all four possible messages, indicating one of the four record-validation rules failed during UnmarshalJSON or FromText.
Source
Thrown at logparser/v6/logly/record/validate.go:29
import "errors"
// validate whether the current record is valid or not.
func (r *Record) validate() error {
var msg string
switch {
case r.Domain == "":
msg = "record.domain cannot be empty"
case r.Page == "":
msg = "record.page cannot be empty"
case r.Visits < 0:
msg = "record.visits cannot be negative"
case r.Uniques < 0:
msg = "record.uniques cannot be negative"
}
if msg != "" {
return errors.New(msg)
}
return nil
}
View on GitHub (pinned to 3c475a78e5)
Solutions
- Fix the offending record field indicated by the message (domain/page/visits/uniques).
- Validate/normalize input JSON before calling UnmarshalJSON or FromText.
- Use the typed record validation to pre-screen batches and skip invalid rows.
- Update importers to fill defaults for missing domain/page and clamp negative counters.
Example fix
// before
{"page":"/home","visits":-1}
// after
{"domain":"example.com","page":"/home","visits":0} Defensive patterns
Strategy: validation
Validate before calling
func validRecord(r logly.Record) bool {
return r.Domain != "" && r.Page != "" && r.Visits >= 0 && r.Uniques >= 0
}
if !validRecord(rec) { skipBatch() } Type guard
func (r Record) IsValid() bool {
return r.Domain != "" && r.Page != "" && r.Visits >= 0 && r.Uniques >= 0
} Try / catch
err := rec.UnmarshalJSON(data)
if err != nil {
var msg string
switch {
case strings.Contains(err.Error(), "domain cannot be empty"):
msg = "missing domain"
case strings.Contains(err.Error(), "visits cannot be negative"):
msg = "negative visits"
// ...
}
log.Printf("invalid record (%s): %s", msg, data)
} Prevention
- Pre-screen records with IsValid before unmarshaling
- Fill defaults for missing domain/page in importers
- Clamp negative counters at the ETL layer
- Test migrations from v5 data for invalid records
When it happens
Trigger: UnmarshalJSON or FromText receives a record that violates any rule: empty Domain, empty Page, negative Visits, or negative Uniques.
Common situations: Migrating v5 pipelines to v6 where old invalid data resurfaces; JSON feeds missing required keys; negative counters from diff-based ETL.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- record.domain cannot be empty
- record.page cannot be empty
- invalid number
- record.visits cannot be negative
- record.uniques cannot be negative
AI-assisted analysis of inancgumus/learngo@3c475a78e5 (2026-09-02).
Data as JSON: /api/errors/d97e39f1bb28b7dd.
Report an issue: GitHub.