fix: map fqdn to domains for Coolify API compatibility#125
fix: map fqdn to domains for Coolify API compatibility#125StuMason merged 2 commits intoStuMason:mainfrom
Conversation
- Add mapFqdnToDomains helper function - Apply mapping in createApplicationPublic, createApplicationPrivateGH, createApplicationPrivateKey, and updateApplication - Coolify API uses 'domains' field, not 'fqdn' - Add tests covering fqdn → domains conversion in all affected methods Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the fqdn field was silently ignored when creating or updating applications, because the Coolify API expects the field to be named domains instead. The fix introduces a helper function mapFqdnToDomains that transparently converts fqdn to domains before sending requests, providing backward compatibility for callers.
Changes:
- Added
mapFqdnToDomainshelper function to mapfqdn→domainsfor Coolify API compatibility - Applied the helper to 4 methods:
createApplicationPublic,createApplicationPrivateGH,createApplicationPrivateKey, andupdateApplication - Added 5 comprehensive tests covering the mapping behavior
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/lib/coolify-client.ts | Added mapFqdnToDomains helper and applied it to 4 application create/update methods |
| src/tests/coolify-client.test.ts | Added 5 tests verifying fqdn → domains mapping works correctly |
| CHANGELOG.md | Documented the fix in version 2.6.3 release notes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Refactor mapFqdnToDomains to destructure first, avoid unsafe type cast when fqdn is undefined - Use mapped.docker_compose_raw instead of data.docker_compose_raw for consistency in updateApplication - Add combined fqdn + docker_compose_raw test for updateApplication Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Incredible @terry90918, thanks for this and for the deepdive too, really appreciate it!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #125 +/- ##
==========================================
+ Coverage 91.33% 91.44% +0.10%
==========================================
Files 1 1
Lines 404 409 +5
Branches 111 112 +1
==========================================
+ Hits 369 374 +5
Misses 6 6
Partials 29 29 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Closes #126
Summary
domainsfield for setting application domain, notfqdnmapFqdnToDomainshelper that transparently convertsfqdn→domainsbefore sending requestscreateApplicationPublic,createApplicationPrivateGH,createApplicationPrivateKey, andupdateApplicationfqdnfield now work correctly without any breaking changesRoot Cause
When creating or updating applications with a custom domain, passing
fqdn: "https://app.example.com"was silently ignored by the Coolify API because it expects the field to be nameddomains. This meant domain settings were never applied.Historical Evidence
Git archaeology on
coollabsio/coolifyshowsdomainshas been the correct API field since the very beginning:cd8509411Applications.phpcreated — GET endpoints only, nofqdnordomains30b7e831domainsintroduced as the API input field insharedDataApplications().$fqdnis only an internal PHP variable ($fqdn = $request->domains) that writes to the DB columnda6f2da3extraFieldsstrict validation introduced — passingfqdntriggers 422"This field is not allowed"32e047e5nullfordomains— fixed todata_get($application, 'fqdn')ce3cae3fdomainsbecomesnullableKey points:
fqdnwas never a valid API input field —sharedDataApplications()has always listeddomains, neverfqdnfqdnaccidentally worked viafill($request->all())before strict validation was addeddomainshas been correct for ~1.5 years (beta.307) —try/fallbackor version detection are not neededDesign options
Option A (this PR): Keep
fqdnin TypeScript types, map silently → no breaking change for existing callersOption B: Rename
fqdn→domainsinCreateApplicationPublicRequest/UpdateApplicationRequestand updatemcp-server.ts→ types match the API exactly, helper removed. Sincefqdnwas always silently broken, this could be argued as a non-breaking fix.Happy to update either way — feedback welcome.
Changes
src/lib/coolify-client.ts— AddedmapFqdnToDomainsgeneric helper and applied it in the 4 affected methodssrc/__tests__/coolify-client.test.ts— Added 6 tests covering:CHANGELOG.md— Added entry under new[2.6.3]versionTest plan
fqdnis correctly renamed todomainsin request bodyfqdnkey is absent from the final request bodyfqdnare unaffected🤖 Generated with Claude Code