Repository navigation
perf(dns): filter Infomaniak records server-side when upserting - #5356
Merged
narcisonunez merged 1 commit intoSep 8, 2026
Merged
Conversation
upsertRecord pulled every record of a zone just to find the one it was about to
write. The API can filter, so ask it to.
The match is still verified locally, because filter[source] matches substrings
rather than exact values. Verified against a live account:
filter[source]=autoconfig -> [autoconfig]
filter[source]=auto -> [autoconfig, autodiscover]
filter[source]=disco -> [autodiscover]
Letting the filter decide would therefore have upserted "auto" onto the existing
"autoconfig" record. The filter narrows what is transferred; the exact
comparison still decides. Covered by a test that fails if the first candidate is
trusted.
The apex was the other thing worth checking, since Infomaniak writes it as ".":
filter[source]=. does return the apex records, and an upsert on an existing apex
TXT returns its id rather than creating a second one.
Suggested by @narcisonunez on Dokploy#5257.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
narcisonunez
approved these changes
Sep 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR about?
Follow-up to the review on #5257.
upsertRecordlisted every record of a zone just to find the one it was about to write, which @narcisonunez pointed out is expensive on large zones. The API supports filtering, so this asks it to filter.The filter matches substrings, so it narrows but does not decide
This is the part worth reviewing.
filter[source]is documented with a bare subdomain example (filter[source]=www), and testing it against a live account shows it matches substrings rather than exact values:So the straightforward version of this change — take the first result the filter returns — would have upserted
autoonto the existingautoconfigrecord and silently overwritten it. The exact comparison is therefore kept on the filtered result: the filter narrows what is transferred over the wire, and the local check still decides what matches. There is a test that fails if the first candidate is trusted.The apex was the other thing to check, since Infomaniak represents it as
"."rather than an empty source.filter[source]=.does return the apex records, and an upsert against an existing apexTXTreturns its id instead of creating a second one — verified end to end, since a duplicate at the apex on a zone with MX or SPF records is how mail breaks.Two smaller behaviours noted while testing: an empty
filter[source]is rejected with a validation error (unreachable here —toSourcewrites"."for the apex, never""), and a source with no match returns an empty array as expected.listZoneRecordsis unchanged and still used bylistRecords, which legitimately needs the whole zone.Checklist
Before submitting this PR, please make sure that:
canarybranch.Tested against a real Infomaniak account: record creation, an upsert that finds the existing record through the filter and returns its id rather than duplicating, and an upsert on an existing apex record. The test zone was left with exactly its original records.
pnpm -r run typecheckpasses and the DNS suite is green (85 tests).Issues related (if applicable)
Follow-up to a review comment on #5257.
Screenshots (if applicable)
N/A — no user-visible change.
Greptile Summary
This PR reduces Infomaniak upsert lookup cost by filtering DNS records by source and type at the API while retaining an exact local comparison to prevent substring matches from selecting the wrong record.
Confidence Score: 5/5
The PR appears safe to merge, with no concrete correctness, security, or repository-rule violations identified.
The filtered lookup retains the exact matching behavior that controls update versus create, and the added tests cover both parameter serialization and the documented substring-overmatch case.
Reviews (1): Last reviewed commit: "perf(dns): filter Infomaniak records ser..." | Re-trigger Greptile