modmuss50 / mod-publish-plugin

A Gradle plugin to publish mods to a range of destinations
https://modmuss50.github.io/mod-publish-plugin/
MIT License
56 stars 9 forks source link

'gameVersions' metadata is less than minimum length (1) #12

Closed ApexModder closed 1 year ago

ApexModder commented 1 year ago

Continued from #11

ok that fixed that issue but.... now we have a new issue, it wants an array of length 1 minimum

> Task :fabric:publishCurseforge FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':fabric:publishCurseforge'.
> A failure occurred while executing me.modmuss50.mpp.platforms.curseforge.Curseforge$UploadWorkAction
   > Request failed, status: 400 message: Error in field `metadata`:
     * Array item count 0 is less than minimum count of 1. Path 'gameVersions', line 1, position 132.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
ApexModder commented 1 year ago

This seems to be related to additionalFiles as those are being uploaded with an emptyList

https://github.com/modmuss50/mod-publish-plugin/blob/1368039fea48934d1fa802f93865d00219ed5db7/src/main/kotlin/me/modmuss50/mpp/platforms/curseforge/Curseforge.kt#L131-L133

changing this to use the same set of gameVersions, seems to fix this issue from my local-testing

```diff --- a/src/main/kotlin/me/modmuss50/mpp/platforms/curseforge/Curseforge.kt +++ b/src/main/kotlin/me/modmuss50/mpp/platforms/curseforge/Curseforge.kt @@ -129,7 +129,7 @@ abstract class Curseforge @Inject constructor(name: String) : Platform(name), Cu } for (additionalFile in additionalFiles.files) { - val additionalMetadata = metadata.copy(parentFileID = response.id, gameVersions = emptyList()) + val additionalMetadata = metadata.copy(parentFileID = response.id) val additionalResponse = HttpUtils.retry(maxRetries.get(), "Failed to upload additional file") { api.uploadFile(projectId.get(), additionalFile.toPath(), additionalMetadata) ```

This would also explain why the files are uploading to their respective platforms but also crashing gradle saying its failing.

The main file is uploading fine as it has all the required details, but the additional files are missing the gameVersions data, successful upload but also crash.

modmuss50 commented 1 year ago

Yeah, sorry about this. I have had a few attempts at fixing this, first https://github.com/modmuss50/mod-publish-plugin/commit/8c97a305d0c443cebe5f775bf7009dce8e689057 and https://github.com/modmuss50/mod-publish-plugin/commit/1368039fea48934d1fa802f93865d00219ed5db7

I have been a bit lazy and tried to fix it without testing, the curseforge documentation is not clear at all about the expected behaviour here. I will find some time to figure this out.

ApexModder commented 1 year ago

yeah, I have been trying to implement a fix myself but this kinda feels like some issue in CurseForge's API?

These 2 rules in the API, feel like they contradict each other, making it impossible to upload parented files to CurseForge.