Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

ShellInputProvider inputs are not consumed by `ComponentFlow`-based interactive components (e.g. `ConfirmationInput`, `StringInput`)

未关闭
#1,383 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
java, spring
领域
cli, testing

调研方向

Start with ShellInputProvider.Builder#withInput(String) and the ComponentFlow input-consumption path, using the shown ExampleCommandTest as the reproducer. Confirm that the two queued inputs populate the sequential string and confirmation steps, and that the test completes with confirm set to true.

由索引模型根据 Issue 内容生成。

描述

type/enhancement

When a command runs a ComponentFlow with two sequential steps and the test supplies two queued inputs via ShellInputProvider.Builder#withInput(String), the flow throws a NoSuchElementException on the second step's context key — regardless of the value supplied (tested with "y", "yes", "true").

Steps to reproduce

Command under test:

@Component
public class ExampleCommand {

    private final ComponentFlow.Builder builder;

    public ExampleCommand(ComponentFlow.Builder builder) {
        this.builder = builder;
    }

    @Command(name = "example")
    public String example() {
        ComponentFlow flow = builder.clone().reset()
            .withStringInput("reason")
                .name("Reason:")
                .and()
            .withConfirmationInput("confirm")
                .name("Confirm?")
                .and()
            .build();

        ComponentFlow.ComponentFlowResult result = flow.run();
        boolean confirmed = result.getContext().get("confirm");
        return confirmed ? "Confirmed" : "Cancelled";
    }
}

Test:

@ShellTest
@ContextConfiguration(classes = ExampleApplication.class)
class ExampleCommandTest {

    @Test
    void testExample(@Autowired ShellTestClient client) throws Exception {
        ShellInputProvider provider = ShellInputProvider.providerFor("example")
            .withInput("some reason")
            .withInput("true")
            .build();

        ShellScreen screen = client.sendCommand(provider);

        ShellAssertions.assertThat(screen).containsText("Confirmed");
    }
}
Expected behavior

The queued inputs are consumed sequentially by the ComponentFlow steps, and the flow completes with confirm = true.

Actual behavior
java.util.NoSuchElementException: Context does not contain key: confirm
	at org.springframework.shell.jline.tui.component.context.BaseComponentContext.get(BaseComponentContext.java:44)
	at ExampleCommand.example(ExampleCommand.java:...)
	...

The exception is identical regardless of the value queued via withInput(...) (tried "y", "yes", "true"), which suggests the input is never reaching the ComponentFlow/ConfirmationInput reading mechanism at all, rather than being rejected as an invalid value.

Is ComponentFlow end-to-end testing currently expected to be unsupported in 4.0.3, or is there a recommended workaround I'm missing?

主要语言
Java
星标
826
派生
404
平均合并
6 天 9 小时
30 天内合并 PR
1

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

spring-projects/spring-shell 的其他 Issue

查看 spring-projects/spring-shell 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。