Skip to content

refactor: clean up type casting in region resolution#10504

Open
wandamora wants to merge 2 commits into
mainfrom
morawand-refactor-endpoint-types
Open

refactor: clean up type casting in region resolution#10504
wandamora wants to merge 2 commits into
mainfrom
morawand-refactor-endpoint-types

Conversation

@wandamora
Copy link
Copy Markdown
Contributor

@wandamora wandamora commented May 12, 2026

Description

Introduces a minimal interface for resolving default regions for better type-safety. This includes refactors in both prepare.ts and ailogic.ts.

@wandamora wandamora force-pushed the morawand-refactor-endpoint-types branch from 82b9be1 to 6320284 Compare May 12, 2026 23:02
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces EventTriggerResolutionTarget and BlockingTriggerResolutionTarget interfaces to replace the use of any and complex intersection types during region resolution. Feedback identifies that BlockingTriggerResolutionTarget is missing a project property and notes an unsafe type cast to backend.Endpoint which circumvents TypeScript safety checks.

Comment thread src/deploy/functions/prepare.ts Outdated
Comment thread src/deploy/functions/prepare.ts
endpoint: backend.Endpoint & backend.BlockingTriggered,
): string {
function resolveRegionForBlockingTrigger(endpoint: TriggerResolutionTarget): string {
if (!endpoint.blockingTrigger) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't love this. Like we should only be calling this for blocking triggers and this was enforced by the old code right with a type of backend.Endpoint & backed.blockingTriggered

This seems to open us up to subtle bugs in the future where we call the wrong region resolution method and then incorrectly fall back to the default function region.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The root problem seems to be that we're trying to construct a single endpoint ish object that has everything the method needs. But we don't really have to do that right? I realize the overall thing is working w/ endpoints and backends. But we don't have to only pass those around.

What if these methods just took individual args for only the info the needed.

E.g. this one only needs the blockingTrigger which already has a type and the resolveRegionForEventTrigger only needs eventTrigger and project?

I guess the issue with that is nominally we need a single interface if we want to in our next refactoring move these methods onto the service so we just call

service.resolveRegionForEventTrigger

But we could just also provide project for blocking triggers even though it's not used?

Thoughts?

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.

3 participants