Problem
parseRepositoryImportJSON directly reads data[0] without an empty-input guard:
The function is currently only called from parseRepositoryImport after trimming and a non-empty check, so this has not been user-visible. But as a shared parser helper it can panic if called with empty data in future code paths (or refactors), and tests could regress this by accidentally passing an empty slice.
Evidence
- File:
internal/cli/cli.go line around 1001
- Direct index in
parseRepositoryImportJSON without len(data) == 0 check.
- Called only by
parseRepositoryImport today, but not protected as a standalone parser contract.
Impact
Potential index out of range panic and crash if the helper is reused without replicating the current precondition in every caller.
Suggested fix
Add a small defensive guard:
if len(data) == 0 {
return nil, errors.New("repository import payload is empty")
}
Problem
parseRepositoryImportJSONdirectly readsdata[0]without an empty-input guard:The function is currently only called from
parseRepositoryImportafter trimming and a non-empty check, so this has not been user-visible. But as a shared parser helper it can panic if called with empty data in future code paths (or refactors), and tests could regress this by accidentally passing an empty slice.Evidence
internal/cli/cli.goline around 1001parseRepositoryImportJSONwithoutlen(data) == 0check.parseRepositoryImporttoday, but not protected as a standalone parser contract.Impact
Potential
index out of rangepanic and crash if the helper is reused without replicating the current precondition in every caller.Suggested fix
Add a small defensive guard: