InseeFrLab / InseeFrLab/onyxia-api
Version parsing not supporting semver pre-release tag for suspend/resume system
- Dominant language
- Java
- Stars
- 34
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
**Scope**
https://github.com/InseeFrLab/onyxia-api
**Describe the bug**
Suspend/Resume on a user service fails with `IllegalArgumentException: Invalid release version ... must be a SemVer 2 string` when the Helm chart version contains a hyphen (e.g. a [SemVer pre-release tag](https://semver.org/)).
**To Reproduce**
1. Install a service whose chart version contains a hyphen, e.g. `0.1.0-abc1234`.
2. Call `POST /my-lab/app/suspend` or `/my-lab/app/resume` with the service ID.
3. API returns 500 with `Invalid release version abc1234, must be a SemVer 2 string`.
**Root cause**
`MyLabController.suspendOrResume()` extracts the chart version by splitting the `chart` field from `helm list` on `lastIndexOf('-')`:
```java
String chart = userService.getChart(); // "chartname-1.2.3-prerelease"
int split = chart.lastIndexOf('-');
String chartName = chart.substring(0, split); // "chartname-1.2.3" ← wrong
String version = chart.substring(split + 1); // "prerelease" ← wrong
```
If the version itself contains a hyphen (valid SemVer 2.0 pre-release), the split grabs only the part after the last hyphen, which lacks `MAJOR.MINOR.PATCH` and fails the strict SemVer regex in `HelmInstallService.installChart()`.
**Expected behavior**
The full SemVer version (pre-release tag included) should be passed to the Helm upgrade command. A workaround on the client side is to never use hyphens in chart versions, but the API should handle this correctly.
**Suggested fix**
Replace `lastIndexOf('-')` with a more robust parsing approach. The chart name is known from the catalog metadata or the Onyxia secret — it shouldn't need to be re-extracted from the `helm list` chart field. Alternatively, use `indexOf('-')` and validate against known chart names.
**Environment**
- onyxia-api v4.11.0
- Charts with versions using SemVer pre-release tags (e.g. `MAJOR.MINOR.PATCH-prerelease`)
*This comment was generated by pi-agent.*
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.