Skip to content

fix: map fqdn to domains for Coolify API compatibility#125

Merged
StuMason merged 2 commits intoStuMason:mainfrom
terry90918:fix/map-fqdn-to-domains
Feb 24, 2026
Merged

fix: map fqdn to domains for Coolify API compatibility#125
StuMason merged 2 commits intoStuMason:mainfrom
terry90918:fix/map-fqdn-to-domains

Conversation

@terry90918
Copy link
Contributor

@terry90918 terry90918 commented Feb 23, 2026

Closes #126

Summary

  • Coolify API uses the domains field for setting application domain, not fqdn
  • Added mapFqdnToDomains helper that transparently converts fqdndomains before sending requests
  • Applied to createApplicationPublic, createApplicationPrivateGH, createApplicationPrivateKey, and updateApplication
  • Callers using the fqdn field now work correctly without any breaking changes

Root 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 named domains. This meant domain settings were never applied.

Historical Evidence

Git archaeology on coollabsio/coolify shows domains has been the correct API field since the very beginning:

Date Commit Event
2024-06-21 cd8509411 Applications.php created — GET endpoints only, no fqdn or domains
2024-06-28 30b7e831 domains introduced as the API input field in sharedDataApplications(). $fqdn is only an internal PHP variable ($fqdn = $request->domains) that writes to the DB column
2024-07-01 da6f2da3 extraFields strict validation introduced — passing fqdn triggers 422 "This field is not allowed"
2025-12-09 32e047e5 Bug fix: POST response was returning null for domains — fixed to data_get($application, 'fqdn')
2026-01-12 ce3cae3f beta.461 — additional restrictions for dockercompose; domains becomes nullable

Key points:

  • fqdn was never a valid API input fieldsharedDataApplications() has always listed domains, never fqdn
  • The accidental window was 3 days (June 28 → July 1, 2024) — fqdn accidentally worked via fill($request->all()) before strict validation was added
  • domains has been correct for ~1.5 years (beta.307) — try/fallback or version detection are not needed

Design options

Option A (this PR): Keep fqdn in TypeScript types, map silently → no breaking change for existing callers

Option B: Rename fqdndomains in CreateApplicationPublicRequest / UpdateApplicationRequest and update mcp-server.ts → types match the API exactly, helper removed. Since fqdn was 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 — Added mapFqdnToDomains generic helper and applied it in the 4 affected methods
  • src/__tests__/coolify-client.test.ts — Added 6 tests covering:
    • fqdn → domains mapping in all 3 create methods
    • fqdn → domains mapping in updateApplication
    • Combined fqdn + docker_compose_raw in updateApplication
    • No-op when fqdn is not provided
  • CHANGELOG.md — Added entry under new [2.6.3] version

Test plan

  • All 235 existing tests pass
  • 6 new tests added and passing
  • fqdn is correctly renamed to domains in request body
  • fqdn key is absent from the final request body
  • Requests without fqdn are unaffected

🤖 Generated with Claude Code

- 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>
Copilot AI review requested due to automatic review settings February 23, 2026 15:02
@terry90918 terry90918 requested a review from StuMason as a code owner February 23, 2026 15:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 mapFqdnToDomains helper function to map fqdndomains for Coolify API compatibility
  • Applied the helper to 4 methods: createApplicationPublic, createApplicationPrivateGH, createApplicationPrivateKey, and updateApplication
  • 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>
Copy link
Owner

@StuMason StuMason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incredible @terry90918, thanks for this and for the deepdive too, really appreciate it!

@StuMason StuMason merged commit 2c4d218 into StuMason:main Feb 24, 2026
8 checks passed
@codecov
Copy link

codecov bot commented Feb 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.44%. Comparing base (1380736) to head (e07ea85).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

StuMason added a commit that referenced this pull request Feb 25, 2026
- fix: map fqdn to domains for Coolify API compatibility (#125)
- fix: correct API path for listing application deployments (#120)
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.

bug: fqdn field not sent correctly to Coolify API (should be domains)

3 participants