Skip to content

tests: resolve sam init menu positions dynamically in schemas tests - #9151

Open
roger-zhangg wants to merge 1 commit into
developfrom
fix-init-schemas-runtime-position
Open

tests: resolve sam init menu positions dynamically in schemas tests#9151
roger-zhangg wants to merge 1 commit into
developfrom
fix-init-schemas-runtime-position

Conversation

@roger-zhangg

Copy link
Copy Markdown
Member

Which issue(s) does this change fix?

N/A

Why is this change necessary?

test_init_interactive_with_event_bridge_app_aws_schemas_python is failing (run 30657529336).

The test answered the runtime prompt with 8 and its comment said # 8: Python 3.9. But the prompt offers 15 runtimes for the Infrastructure event management use case, and position 8 is now java8.al2023python3.9 has drifted to position 10:

 1. go (provided.al2)   6. java11.al2023   11. python3.14
 2. java25              7. java11          12. python3.13
 3. java21              8. java8.al2023 <- test picked this
 4. java17.al2023       9. java8.al2       13. python3.12
 5. java17             10. python3.9 <- wanted    ...

So the test selected a Java runtime and then fed Python-flow answers (eb-app-python39, schema paginator choices) into a Java prompt sequence. Every later answer landed on the wrong question, and it finally asserted on hello_world_function/schema — a Python layout a Java project never produces.

The positions moved when java8.al2023 / java11.al2023 / java17.al2023 were added (#9125).

How does it address the issue?

Adds _get_runtime_position and _get_use_case_position, which resolve positions from the same source the prompt uses (InitTemplates().get_preprocessed_manifest(...) + get_sorted_runtimes) rather than hardcoding an index. This mirrors the existing _get_registry_position helper already in the file.

All 8 tests now resolve template/use-case/runtime answers dynamically. The 4 Java tests and the go test were relying on the same brittle indexing and only passed by luck — a future runtime addition would have broken them the same way.

Resolved positions are unchanged for Java (4) and go (1), and corrected from 8 → 10 for python3.9. Stale comments now name the runtime instead of a number.

What side effects does this change have?

The helpers call get_preprocessed_manifest, which these tests already exercise via sam init itself, so no new external dependency. If a runtime is ever removed from the manifest the helper raises with the available list, which fails loudly instead of silently selecting the wrong runtime.

Note the same job also hit a separate pytest-xdist crash (struct.error: 'i' format requires ... <= 2147483647 — a worker tried to send a >2 GiB test report, killing the session and taking ..._non_default_profile_selection with it). That is very likely a consequence of the misaligned answers producing runaway prompt output, so this fix should resolve it, but the 2 GiB report limit is a separate robustness issue not addressed here.

Mandatory Checklist

PRs will only be reviewed after checklist is complete

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

test_init_interactive_with_event_bridge_app_aws_schemas_python has been
failing (see run 30657529336). It answered the runtime prompt with "8" and
its comment said "8: Python 3.9", but the prompt offers 15 runtimes for the
Infrastructure event management use case and position 8 is now java8.al2023.
python3.9 has drifted to position 10.

The test therefore selected a Java runtime and fed Python-flow answers into a
Java prompt sequence: every later answer landed on the wrong question, and it
finally asserted on hello_world_function/schema, a Python layout a Java
project never produces.

The positions moved when java8.al2023/java11.al2023/java17.al2023 were added
(#9125). Nothing about the runtime list is stable, so hardcoding an index
means any future runtime addition silently repoints these tests at a
different runtime -- a failure that looks like a product bug rather than a
stale fixture.

Adds _get_runtime_position and _get_use_case_position, which look positions
up from the same source the prompt uses (InitTemplates().
get_preprocessed_manifest plus get_sorted_runtimes), mirroring the existing
_get_registry_position helper. All 8 tests in the file now resolve the
template/use-case/runtime answers dynamically; the 4 Java tests and the go
test were relying on the same brittle indexing and only passed by luck.

Resolved positions are unchanged for Java (4) and go (1), and corrected from
8 to 10 for python3.9. Stale position comments updated to name the runtime
rather than a number.

Testing: make pr passes (9347 passed, 25 skipped, coverage 94.09%). Verified
the helpers resolve to use case 8, java17.al2023 4, python3.9 10,
go (provided.al2) 1, and rendered each test's user_input to confirm the
answer sequences.
@roger-zhangg
roger-zhangg requested a review from a team as a code owner July 31, 2026 22: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.

1 participant