Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25.7'
go-version: '1.25.x'
cache: true

- name: Download dependencies
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25.7'
go-version: '1.25.x'
cache: true

- name: Build
Expand All @@ -68,7 +68,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25.7'
go-version: '1.25.x'
cache: true

- name: Check GoReleaser config
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25.7'
go-version: '1.25.x'
cache: true

- name: Run GoReleaser
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/shantoislamdev/kothaset

go 1.25.7
go 1.24.1

require (
github.com/google/uuid v1.6.0
Expand Down
5 changes: 2 additions & 3 deletions internal/cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,8 @@ func validateJSONL(path string) (int, error) {
if line == "" {
continue
}
var obj map[string]any
if err := json.Unmarshal([]byte(line), &obj); err != nil {
return count, fmt.Errorf("line %d: invalid JSON: %w", lineNum, err)
if !json.Valid([]byte(line)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject non-object JSONL records

Switching to json.Valid changes validate dataset semantics from “line is a JSON object” to “line is any JSON value”, so files containing lines like [], "text", or 123 will now be reported as valid rows. KothaSet writes dataset rows as objects (see schema ToJSONL methods marshaling sample.Fields), so this creates false positives where structurally invalid datasets pass validation and are only discovered later in downstream use.

Useful? React with 👍 / 👎.

return count, fmt.Errorf("line %d: invalid JSON", lineNum)
}
count++
}
Expand Down
28 changes: 28 additions & 0 deletions internal/cli/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,31 @@ global:
t.Fatalf("expected config path validation to pass, got: %v", err)
}
}

func BenchmarkValidateJSONL(b *testing.B) {
// Create a temporary JSONL file with 1000 lines
dir := b.TempDir()
path := filepath.Join(dir, "test.jsonl")
file, err := os.Create(path)
if err != nil {
b.Fatal(err)
}

jsonLine := `{"id": "12345", "name": "John Doe", "email": "john.doe@example.com", "isActive": true, "roles": ["admin", "user"], "metadata": {"created_at": "2023-01-01T00:00:00Z", "login_count": 42}}` + "\n"

for i := 0; i < 1000; i++ {
file.WriteString(jsonLine)
}
file.Close()

b.ResetTimer()
for i := 0; i < b.N; i++ {
count, err := validateJSONL(path)
if err != nil {
b.Fatal(err)
}
if count != 1000 {
b.Fatalf("expected 1000 rows, got %d", count)
}
}
}
Loading