Skip to content

[APPS][Connections Part 3] Resolve same-module connection ID constants#351

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
sdkennedy2/same-module-connection-id-values
May 11, 2026
Merged

[APPS][Connections Part 3] Resolve same-module connection ID constants#351
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
sdkennedy2/same-module-connection-id-values

Conversation

@sdkennedy2
Copy link
Copy Markdown
Collaborator

@sdkennedy2 sdkennedy2 commented May 8, 2026

Motivation

This builds on the inline connection ID extractor from #349. Inline string literals are safe, but backend code commonly assigns a connection ID to a same-file constant before passing it to action-catalog.

This PR adds the smallest useful same-module value resolver first so the follow-up object-map PR can be reviewed separately.

Changes

Adds same-module static value resolution for direct constant forms:

const CONNECTION_ID = '77c14b8b-27e1-4901-985d-8817908b9706';
request({ connectionId: CONNECTION_ID, inputs: {} });

The resolver tracks declarations by eslint-scope variable identity, preserving shadowing behavior from #349. It supports top-level same-file const strings, exported top-level consts, const-to-const chains, and static template literals without interpolation.

It intentionally rejects member expressions such as CONNECTIONS.HTTP, imported values, mutable bindings, function-local bindings, dynamic templates, calls, binary expressions, environment reads, and const cycles. Same-module object-map support is split into the next PR.

QA Instructions

Ran:

yarn workspace @dd/tests test:unit packages/plugins/apps/src/backend/ast-parsing/extract-connection-ids.test.ts --runInBand

Parent branch result: 46 tests passed.

Blast Radius

This affects Apps backend function discovery/upload/dev-server manifest generation for action-catalog connection allowlists. Runtime backend execution is unchanged. Unsupported known action-catalog connectionId forms fail closed instead of producing an incomplete allowlist.

Documentation

Copy link
Copy Markdown
Collaborator Author

sdkennedy2 commented May 8, 2026

@sdkennedy2 sdkennedy2 changed the title Resolve same-module connection ID values [APPS] Resolve same-module connection ID values May 8, 2026
@sdkennedy2 sdkennedy2 changed the base branch from sdkennedy2/poc-eslint-scope-walker to graphite-base/351 May 8, 2026 17:44
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/same-module-connection-id-values branch from 6cea58a to d7aca74 Compare May 8, 2026 17:44
@sdkennedy2 sdkennedy2 changed the base branch from graphite-base/351 to sdkennedy2/refactor-connection-id-extraction-modules May 8, 2026 17:44
@sdkennedy2 sdkennedy2 changed the title [APPS] Resolve same-module connection ID values [APPS][Connections Part 4] Resolve same-module connection ID values May 8, 2026
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/same-module-connection-id-values branch 6 times, most recently from 958f598 to 903a98b Compare May 8, 2026 18:15
@sdkennedy2 sdkennedy2 changed the title [APPS][Connections Part 4] Resolve same-module connection ID values [APPS][Connections Part 3] Resolve same-module connection ID values May 8, 2026
@sdkennedy2 sdkennedy2 changed the base branch from sdkennedy2/refactor-connection-id-extraction-modules to graphite-base/351 May 8, 2026 19:11
@sdkennedy2 sdkennedy2 changed the base branch from graphite-base/351 to sdkennedy2/poc-eslint-scope-walker May 8, 2026 19:11
Base automatically changed from sdkennedy2/poc-eslint-scope-walker to master May 8, 2026 21:54
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/same-module-connection-id-values branch from ec55fa9 to 908d3d4 Compare May 10, 2026 21:41
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/same-module-connection-id-values branch from 908d3d4 to cd42b54 Compare May 11, 2026 13:11
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/same-module-connection-id-values branch from cd42b54 to 2a5b6a3 Compare May 11, 2026 13:16
@sdkennedy2 sdkennedy2 changed the title [APPS][Connections Part 3] Resolve same-module connection ID values [APPS][Connections Part 3] Resolve same-module connection ID constants May 11, 2026
case 'Identifier':
return resolveIdentifierValue(node, context);
default:
throw unsupportedConnectionId(context.filePath, `unsupported ${node.type} values`);
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We will expand upon this in a further PR (#354) to support object values such as CONNECTIONS.HTTP (

// Imported values require following another module, which is deferred to
// the module graph PR:
// import { HTTP_CONNECTION_ID } from './connections';
throw unsupportedConnectionId(
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We plan on handling this in a future PR.

@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/same-module-connection-id-values branch from 2a5b6a3 to 2826a40 Compare May 11, 2026 13:27
// const HTTP_CONNECTION_ID = 'abc';
// request({ connectionId: HTTP_CONNECTION_ID });
// }
throw unsupportedConnectionId(
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Its probably worth handling this in a followup PR.

@sdkennedy2
Copy link
Copy Markdown
Collaborator Author

@codex review
@cursor review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sdkennedy2 sdkennedy2 marked this pull request as ready for review May 11, 2026 14:33
@sdkennedy2 sdkennedy2 requested review from a team and yoannmoinet as code owners May 11, 2026 14:33
const { value } = connectionIdProperty;
if (value.type === 'Literal' && typeof value.value === 'string') {
return value.value;
return resolveConnectionIdValue(connectionIdProperty.value as Expression, {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: if we don't want to cast as Expression, we could narrow findConnectionIdProperty's return type to Property & { value: Expression }

type ConnectionIdProperty = Property & { value: Expression };

function hasExpressionValue(property: Property): property is ConnectionIdProperty {
    const { value } = property;
    return (
        value.type !== 'ObjectPattern' &&
        value.type !== 'ArrayPattern' &&
        value.type !== 'RestElement' &&
        value.type !== 'AssignmentPattern'
    );
}

function findConnectionIdProperty(
    objectExpression: ObjectExpression,
    filePath: string,
): ConnectionIdProperty | undefined {
    let connectionIdProperty: ConnectionIdProperty | undefined;
    
    ...

            if (!hasExpressionValue(property)) {
                throw unsupportedActionCatalogCall(
                    filePath,
                    'destructuring pattern in connectionId value',
                );
            }
            connectionIdProperty = property;
        }
    }
    return connectionIdProperty;
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good call 👍. I'll make the change.

@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/same-module-connection-id-values branch from 2826a40 to acbf509 Compare May 11, 2026 16:54
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 13307e9 into master May 11, 2026
6 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the sdkennedy2/same-module-connection-id-values branch May 11, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants