goharbor / goharbor/harbor-cli
[bug]: storage limit validation is currently inconsistent and contains logic bugs
- Dominant language
- Go
- Stars
- 163
- Forks
- 211
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
## Description
The Harbor CLI's storage limit validation is currently restrictive and contains logic bugs that prevent users from using standard units or limits exceeding 1024 bytes.
- Logic Bug: The validation helper contains an impossible condition (storageLimit > -1 && storageLimit < 0).
- Incorrect Limit Check: The check storageLimit > 1024 incorrectly treats the value as bytes instead of terabytes, effectively capping storage at 1KB.
- Missing Error Handling: API handlers like CreateProject ignore parsing errors, leading to silent failures where invalid inputs are treated as 0.
## Steps to Reproduce
1. Run command: `harbor project create`
2. With arguments/config: `Interactive mode, enter 10GB for the storage limit.`
3. Observe error the storage limit only takes integer values
## Expected Behavior
The CLI should support standard binary units (MiB, GiB, TiB) and correctly convert them to bytes. In interactive mode, a unit selection field should be provided. A value of -1 should be accepted for unlimited storage.
## Actual Behavior
The CLI only accepts plain integers and fails for any string containing units. Additionally, any value greater than 1024 (bytes) is rejected due to an incorrect hardcoded limit check in the validator.
## Environment
- OS: any
- Tool version:harbor-cli (latest main)
- Other relevant details: go 1.2.1+
## Additional Context
Contributor guide
Assessment
This issue has not been assessed yet.