fix(modpack-checker): Code review fixes — license, safety, and polish

Fixes 10 issues from full code review:
- License corrected from MIT to Commercial
- Deprecated datetime.utcnow() replaced with timezone-aware alternative
- PHP array bounds checks added for all platform API responses
- Modrinth file detection now derives project slug instead of using MC version
- validate_api_key() no longer swallows network errors
- HTTP timeouts added to all external API calls in PHP
- Empty API key rejection added to CLI
- Corrupted config now warns on stderr instead of failing silently
- Error response format made consistent across controller
- Docs updated with correct repo URL and clearer CurseForge ID instructions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude (Chronicler #83 - The Compiler)
2026-04-12 13:37:26 -05:00
parent c6d40dcf39
commit 3457b87aef
8 changed files with 40 additions and 27 deletions

View File

@@ -103,7 +103,9 @@ class ModpackAPIController extends Controller
if (empty($platform) || empty($modpackId)) {
return response()->json([
'success' => false,
'message' => 'Could not detect modpack. Set MODPACK_PLATFORM and MODPACK_ID in startup variables.',
'platform' => $platform ?? null,
'modpack_id' => $modpackId ?? null,
'error' => 'Could not detect modpack. Set MODPACK_PLATFORM and MODPACK_ID in startup variables.',
]);
}
@@ -174,9 +176,12 @@ class ModpackAPIController extends Controller
if ($modrinthIndex) {
$data = json_decode($modrinthIndex, true);
if (isset($data['formatVersion'])) {
// Use the pack name as the Modrinth project slug for API lookups.
// dependencies.minecraft is a MC version (e.g. "1.20.1"), NOT a project ID.
$slug = isset($data['name']) ? strtolower(str_replace(' ', '-', $data['name'])) : null;
return [
'platform' => 'modrinth',
'modpack_id' => $data['dependencies']['minecraft'] ?? null,
'modpack_id' => $slug,
'name' => $data['name'] ?? null,
'version' => $data['versionId'] ?? null,
];