Skip to content

fix(lambda): accept ARN, partial ARN, qualified names in URL paths#822

Merged
vieiralucas merged 2 commits intomainfrom
worktree-lambda-getfunction-arn-817
Apr 28, 2026
Merged

fix(lambda): accept ARN, partial ARN, qualified names in URL paths#822
vieiralucas merged 2 commits intomainfrom
worktree-lambda-getfunction-arn-817

Conversation

@vieiralucas
Copy link
Copy Markdown
Member

@vieiralucas vieiralucas commented Apr 28, 2026

Summary

Closes #817.

The VS Code AWS Toolkit calls GetFunction with a fully-qualified function ARN. Real AWS Lambda accepts ARN, partial ARN (ACCOUNT:function:NAME), and name:qualifier in any URL slot that names a function. fakecloud was looking up the raw URL segment in the in-memory map keyed by short name, so every toolkit request returned 404 and the Lambda explorer in the IDE showed nothing.

  • New normalize_function_name helper strips full ARN, partial ARN, and trailing :qualifier down to the bare name. Percent-decodes first since SDKs URL-encode : in path segments (arn%3A...).
  • Applied at dispatch: handle() normalizes the resource name for every action that takes a FunctionName (Get/Delete/Invoke/aliases/concurrency/URL config/event invoke config/recursion config/versions/policy/scaling). Layer and event-source-mapping routes are untouched.

Test plan

  • 8 unit tests for the normalizer (bare name, qualifier strip, full ARN, qualified full ARN, partial ARN, malformed ARN passthrough, empty, percent-encoded ARN)
  • 3 unit tests exercising LambdaService::handle end-to-end with full ARN, partial ARN, and name:qualifier
  • 1 e2e test via aws-sdk-lambda calling GetFunction with all three forms — same code path the VS Code toolkit hits
  • cargo clippy --workspace --all-targets -- -D warnings clean
  • cargo fmt --all clean
  • VS Code AWS Toolkit smoke test against running fakecloud (manual, post-merge)

Summary by cubic

Accept full ARNs, partial ARNs, and name:qualifier in Lambda function URL paths to match AWS behavior. This fixes GetFunction 404s from the VS Code AWS Toolkit so functions appear in the IDE.

  • Bug Fixes

    • Added a normalizer that percent-decodes and strips full/partial ARNs and trailing qualifiers to the bare function name.
    • Applied at dispatch to all actions that take FunctionName, including runtime management and durable-executions routes; layer and event-source-mapping routes are unchanged.
  • Dependencies

    • Added percent-encoding for URL-decoding path segments.

Written for commit 55daeeb. Summary will update on new commits. Review in cubic

Closes #817.

The VS Code AWS Toolkit calls GetFunction with a fully-qualified
function ARN (`arn:aws:lambda:REGION:ACCOUNT:function:NAME`), which
real AWS Lambda accepts in any URL slot that names a function.
fakecloud was looking up the raw URL segment in the in-memory map
keyed by short name, so every toolkit request returned 404 and the
Lambda explorer in the IDE showed nothing.

The fix:

- New `normalize_function_name` helper strips full ARN, partial ARN
  (`ACCOUNT:function:NAME`), and trailing `:qualifier` (version or
  alias) down to the bare name. Inputs that don't match any of those
  shapes pass through unchanged.
- Helper percent-decodes its input first, since SDKs URL-encode `:`
  in path segments (`arn%3Aaws%3Alambda%3A...`).
- Applied at dispatch: `handle()` normalizes `resource_name` for every
  action that takes a `FunctionName` (Get/Delete/Invoke/etc., aliases,
  concurrency, URL config, event invoke config, recursion config,
  versions, policy, scaling). Layer / event-source-mapping routes are
  untouched — those carry different identifiers.

Coverage:

- 8 unit tests for the normalizer (bare name, qualifier strip, full
  ARN, qualified full ARN, partial ARN, malformed ARN passthrough,
  empty, percent-encoded ARN)
- 3 unit tests exercising `LambdaService::handle` end-to-end with
  full ARN, partial ARN, and `name:qualifier`
- 1 e2e test via aws-sdk-lambda calling `GetFunction` with all three
  forms — same code path the VS Code toolkit hits
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="crates/fakecloud-lambda/src/service.rs">

<violation number="1" location="crates/fakecloud-lambda/src/service.rs:67">
P2: Add the missing function-name actions to action_takes_function_name; otherwise runtime-management-config and durable-executions routes still won't accept ARN/qualified names and will continue to 404 on those endpoints.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread crates/fakecloud-lambda/src/service.rs
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 28, 2026

Codecov Report

❌ Patch coverage is 96.51163% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/fakecloud-lambda/src/service.rs 96.51% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

…n ARN normalization

Cubic catch on #822: PutRuntimeManagementConfig, GetRuntimeManagementConfig,
and ListDurableExecutionsByFunction also live under /functions/{name}/...
and were missing from the action_takes_function_name allowlist, so they
would still 404 on ARN / qualified-name input.
@vieiralucas vieiralucas merged commit dfd58ce into main Apr 28, 2026
57 of 61 checks passed
@vieiralucas vieiralucas deleted the worktree-lambda-getfunction-arn-817 branch April 28, 2026 13:23
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.

Lambda GetFunction does not accept ARN, causing AWS Toolkit for VS Code to fail when listing Lambda functions

1 participant