Skip to content

Fix Appwrite migration runtime cascades#201

Merged
abnegate merged 4 commits into
mainfrom
fix-appwrite-migration-runtime-cascades
Jun 30, 2026
Merged

Fix Appwrite migration runtime cascades#201
abnegate merged 4 commits into
mainfrom
fix-appwrite-migration-runtime-cascades

Conversation

@premtsd-code

@premtsd-code premtsd-code commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add Appwrite runtime mappings for node-23, node-24, and node-25 for functions and sites

Tests

  • .\vendor\bin\phpunit.bat tests\Migration\Unit\General\TransferTest.php
  • composer lint -- --dirty
  • .\vendor\bin\phpstan.bat analyse --level 3 src\Migration\Destinations\Appwrite.php tests\Migration\Unit\General\TransferTest.php --memory-limit 2G

@greptile-apps

greptile-apps Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces the two large, hardcoded match statements that mapped runtime/build-runtime strings to SDK enum cases with dynamic Runtime::from() and BuildRuntime::from() calls, so newly added runtimes (node-23, node-24, node-25, etc.) are automatically supported whenever the SDK enum gains a new case. The error path now catches both \InvalidArgumentException and \ValueError, which is the correct union for a custom from() factory method and a PHP native backed-enum ::from() respectively.

  • Dynamic runtime resolution: Runtime::from($resource->getRuntime()) and BuildRuntime::from($resource->getBuildRuntime()) replace ~130 lines of explicit mappings, removing the need for a code change every time a new runtime is added to the Appwrite SDK.
  • Correct exception handling: The catch union \InvalidArgumentException|\ValueError addresses the previous finding that \ValueError (thrown by PHP 8.1 backed-enum ::from()) extended \Error, not \Exception, and would have been silently unhandled before.

Confidence Score: 5/5

Safe to merge — the two changed blocks are self-contained and the logic is simpler and more future-proof than what it replaces.

The only code touching the diff is the replacement of explicit match tables with Runtime::from() / BuildRuntime::from(). Both calls wrap the SDK method in a try/catch that covers every exception type the SDK can produce on an unrecognised value. No control-flow paths were removed or altered beyond the mapping itself; the rest of importFunctionResource and importSiteResource is unchanged.

No files require special attention.

Important Files Changed

Filename Overview
src/Migration/Destinations/Appwrite.php Replaces two large hardcoded match statements (Runtime and BuildRuntime) with dynamic ::from() calls; error handling now correctly catches both \ValueError and \InvalidArgumentException

Reviews (7): Last reviewed commit: "Remove runtime enum migration tests" | Re-trigger Greptile

Comment thread src/Migration/Destinations/Appwrite.php Outdated
@premtsd-code premtsd-code force-pushed the fix-appwrite-migration-runtime-cascades branch 2 times, most recently from d750b3e to 1596127 Compare June 29, 2026 17:12
Comment thread src/Migration/Destinations/Appwrite.php Outdated
@premtsd-code premtsd-code force-pushed the fix-appwrite-migration-runtime-cascades branch from 1596127 to 43e1b61 Compare June 29, 2026 17:18
@premtsd-code premtsd-code force-pushed the fix-appwrite-migration-runtime-cascades branch from 8a0af2c to a62e524 Compare June 30, 2026 10:56
@abnegate abnegate merged commit 5d319d9 into main Jun 30, 2026
4 checks passed
@abnegate abnegate deleted the fix-appwrite-migration-runtime-cascades branch June 30, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants