Skip to content

Prompt occurs multiple times if re-used in request #118

Closed

Description

@LucasPickering

If the same chained prompt value is used multiple times in a request, it prompts once per usage. It should only prompt once per request.

chains:
  username:
    source: !command ["sh", "-c", "whoami | tr -d '\n'"]
  password:
    source: !prompt Password
    sensitive: true

requests:
  login:
    method: POST
    url: "{{host}}/anything/login"
    query:
      sudo: yes_please
      password: "{{chains.password}}"
    body: |
      {
        "username": "{{username}}",
        "password": "{{chains.password}}"
      }

This is a tough one to fix because each template render is executed independently and in parallel during request build. The solution would probably be to scan all parsed templates at the start of the request, and collect all used chains into a de-duplicated pool. Then resolve those chain values first, before finally rendering the templates themselves. This has the added benefit of de-duplicating other chain types too (e.g. if a slow shell command is chained, it won't have to execute multiple times).

It's very possible, just requires rearchitecting the template code a fair amount.

futures::future::shared may be helpful for caching the futures.

Activity

  1. added 4 commits that reference this issue on Jul 20, 2024
    e1a9713
    2ffe90b
    77f8463
    62069d6
  2. added a commit that references this issue on Dec 22, 2024
    3e56f01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions