Skip to content

[APPS][Connections Part 2] Extract inline backend connection IDs#349

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 15 commits intomasterfrom
sdkennedy2/poc-eslint-scope-walker
May 8, 2026
Merged

[APPS][Connections Part 2] Extract inline backend connection IDs#349
gh-worker-dd-mergequeue-cf854d[bot] merged 15 commits intomasterfrom
sdkennedy2/poc-eslint-scope-walker

Conversation

@sdkennedy2
Copy link
Copy Markdown
Collaborator

@sdkennedy2 sdkennedy2 commented May 7, 2026

Motivation

Backend manifests currently carry required allowedConnectionIds arrays, but they remain empty.

This PR extracts connectionIds that are statically defined within action catalog function calls such as the following:

import { request } from '@datadog/action-catalog/http/http';

export function run() {
    return request({ connectionId: '358b602d-794f-420e-9802-3caca434060a', inputs: {} });
}

This should include '358b602d-794f-420e-9802-3caca434060a' in allowedConnectionIds.

Changes

Adds the inline connection ID extractor in the same module structure used by the follow-up static value resolution work:

  • action-catalog-imports.ts collects action-catalog function and namespace imports.
  • action-catalog-call-sites.ts uses eslint-scope and the internal walkAst helper from [APPS][Connections Part 1] Add internal AST traversal helper #350 to find action-catalog call sites while staying safe around shadowed names and unsupported aliases.
  • connection-id-values.ts reads the connectionId property from a known action-catalog call and extracts inline string literals.
  • extract-connection-ids.ts stays as the small public orchestration layer used by backend proxy module generation.

extractConnectionIds does the following for each *.backend.ts file:

  1. Collects the names imported from the action catalog library.

  2. Uses eslint-scope to map identifiers back to their declarations. This lets us distinguish an actual action-catalog import from a local binding with the same name, such as this shadowed request parameter:

    import { request } from '@datadog/action-catalog/http/http';
    
    export function run(request) {
        return request({ connectionId: 'ignored', inputs: {} });
    }
  3. Uses the internal walkAst helper from [APPS][Connections Part 1] Add internal AST traversal helper #350 to traverse the ESTree AST for each *.backend.ts file.

  4. Finds action-catalog call sites and extracts inline string connectionId values.

  5. Fails closed for action-catalog call shapes that could hide a connection ID.

Added dependencies

  • eslint-scope: despite the name, this package is focused on ESTree scope analysis. It lets us resolve each identifier to the declaration it actually references, which is what makes shadowing-safe extraction possible.
  • rollup as a dev dependency because the tests need parseAst to create the same Rollup ESTree shape that plugin this.parse() provides. Vite re-exports parseAst from its ESM API, but this repo's Jest/ts-jest setup loads Vite through its CJS facade, where Vite intentionally throws for parseAst. Importing rollup/parseAst directly keeps the tests simple and avoids adding a misleading Vite test shim.

QA Instructions

Added extractor tests.

Validated with /Users/scott.kennedy/dd/test-action-catalog-app by building the linked local Vite plugin, redirecting app upload to a local capture server, and inspecting the captured manifest. A temporary backend entrypoint with one inline string connectionId and one shadowed catch (request) call produced only the inline ID in allowedConnectionIds.

Blast Radius

This affects backend manifest connection ID extraction during the apps plugin build/dev-preview flow. It adds a direct eslint-scope runtime dependency to @dd/apps-plugin, plus a rollup dev dependency for parser-backed tests. AST traversal comes from the internal helper added in #350.

Documentation

  • Not applicable.

Copy link
Copy Markdown
Collaborator Author

sdkennedy2 commented May 7, 2026

@sdkennedy2 sdkennedy2 changed the title POC extract connection IDs with eslint-scope [APPS][POC] Extract connection IDs with eslint-scope May 7, 2026
@sdkennedy2
Copy link
Copy Markdown
Collaborator Author

@codex review
@cursor review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5740b4654b

ℹ️ 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".

Comment thread packages/plugins/apps/src/backend/ast-parsing/extract-connection-ids.ts Outdated
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/poc-eslint-scope-walker branch 2 times, most recently from dca9665 to bb15b8c Compare May 7, 2026 19:15
@sdkennedy2 sdkennedy2 changed the title [APPS][POC] Extract connection IDs with eslint-scope [APPS] Extract inline backend connection IDs with eslint-scope May 7, 2026
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/poc-eslint-scope-walker branch 3 times, most recently from 51ffd3b to e8b5f13 Compare May 7, 2026 20:24
Copy link
Copy Markdown
Collaborator Author

@codex review
@cursor review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e8b5f13859

ℹ️ 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".

Comment thread packages/plugins/apps/src/backend/ast-parsing/extract-connection-ids.ts Outdated
@sdkennedy2 sdkennedy2 changed the title [APPS] Extract inline backend connection IDs with eslint-scope [APPS] Extract inline backend connection IDs May 8, 2026
@sdkennedy2 sdkennedy2 marked this pull request as ready for review May 8, 2026 12:42
@sdkennedy2 sdkennedy2 requested review from a team and yoannmoinet as code owners May 8, 2026 12:42
@sdkennedy2 sdkennedy2 marked this pull request as draft May 8, 2026 14:25
@sdkennedy2 sdkennedy2 changed the base branch from master to graphite-base/349 May 8, 2026 16:10
@sdkennedy2 sdkennedy2 force-pushed the sdkennedy2/poc-eslint-scope-walker branch from bc33ec1 to ed2ddae Compare May 8, 2026 16:11
@sdkennedy2 sdkennedy2 changed the base branch from graphite-base/349 to sdkennedy2/ast-parsing-walk-ast May 8, 2026 16:11
Copy link
Copy Markdown
Collaborator Author

AI validation note:

I revalidated this PR with /Users/scott.kennedy/dd/test-action-catalog-app using the linked local @datadog/vite-plugin built from this branch.

Validated paths:

  • Upload/build path: DD_APPS_UPLOAD_ASSETS=1 ... npm run build succeeded, built all 3 backend functions, uploaded the 7-file archive, and published version 02c7302bb790dcef live on staging.
  • Dev-server path: npm run dev plus a direct /__dd/executeAction call succeeded for a backend function with an inline @datadog/action-catalog/http/http connectionId; the HTTP probe returned success: true, ok: true, and status 200.

Scope note: the original test-app shape had the action-catalog call in an imported helper module. That failed closed with Datadog's expected allowlist error because this PR extracts inline connection IDs from the .backend.ts file itself, not from imported helper modules. Moving the action-catalog call into the backend file validated the intended #349 behavior.

@sdkennedy2 sdkennedy2 changed the title [APPS] Extract inline backend connection IDs [APPS][Connections Part 2] Extract inline backend connection IDs May 8, 2026
Base automatically changed from sdkennedy2/ast-parsing-walk-ast to master May 8, 2026 20:35
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 7abbc1b into master May 8, 2026
9 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the sdkennedy2/poc-eslint-scope-walker branch May 8, 2026 21:54
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