Skip to content

fix: fix Create Quote Bruno pre-request script#3883

Open
Onyx2406 wants to merge 1 commit intointerledger:mainfrom
Onyx2406:fix/bruno-create-quote-prerequest
Open

fix: fix Create Quote Bruno pre-request script#3883
Onyx2406 wants to merge 1 commit intointerledger:mainfrom
Onyx2406:fix/bruno-create-quote-prerequest

Conversation

@Onyx2406
Copy link
Copy Markdown

@Onyx2406 Onyx2406 commented Apr 3, 2026

Summary

Fixes the broken "Create Quote" pre-request script in the Bruno API collection.

Root cause: The Create Wallet Address post-response script stored the Bruno req object as an environment variable via bru.setEnvVar('initialWalletAddressRequest', req). However, Bruno environment variables are serialized as strings, so when Create Quote retrieved it with bru.getEnvVar("initialWalletAddressRequest"), the object's properties (.body.query, .url) were undefined, causing the script to fail.

Fix:

  • Inline the CreateWalletAddress GraphQL mutation directly in the Create Quote pre-request script
  • Use bru.getEnvVar("RafikiGraphqlHost") for the URL instead of the stored request object
  • Remove the non-functional setEnvVar('initialWalletAddressRequest', req) from Create Wallet Address

Changes

File Change
bruno/.../Create Quote.bru Inline mutation query, use env var for URL
bruno/.../Create Wallet Address.bru Remove non-functional setEnvVar for request object

Closes #3573

The pre-request script for Create Quote tried to retrieve a stored
request object from environment variables via getEnvVar, but Bruno
environment variables are serialized as strings, so the object's
properties (.body.query, .url) were undefined at runtime.

Fix by inlining the CreateWalletAddress GraphQL mutation directly
in the pre-request script and using the RafikiGraphqlHost env var
for the URL.

Also remove the unnecessary `setEnvVar('initialWalletAddressRequest',
req)` from Create Wallet Address since the request object cannot be
properly serialized to env vars.

Closes interledger#3573
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 3, 2026

Deploy Preview for brilliant-pasca-3e80ec failed. Why did it fail? →

Name Link
🔨 Latest commit 2e761bc
🔍 Latest deploy log https://app.netlify.com/projects/brilliant-pasca-3e80ec/deploys/69cf6f895783ce000923734b

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes the broken Bruno “Create Quote” pre-request script by removing reliance on a serialized req object stored in env vars, and instead constructing a fresh CreateWalletAddress GraphQL request using the configured GraphQL host.

Changes:

  • Removed bru.setEnvVar('initialWalletAddressRequest', req) from “Create Wallet Address” post-response script (non-functional due to env var string serialization).
  • Updated “Create Quote” pre-request script to inline the CreateWalletAddress mutation and call {{RafikiGraphqlHost}}/graphql directly.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
bruno/collections/Rafiki/Rafiki Admin APIs/Create Wallet Address.bru Removes storing the Bruno req object into env vars after response.
bruno/collections/Rafiki/Rafiki Admin APIs/Create Quote.bru Inlines wallet address creation mutation and uses RafikiGraphqlHost for the manual pre-request call.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -65,7 +65,6 @@ script:post-response {
if (body?.data) {
bru.setEnvVar("walletAddressId", body.data.createWalletAddress.walletAddress.id);
bru.setEnvVar("walletAddressUrl", body.data.createWalletAddress.walletAddress.url);
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

walletAddressUrl is being set from body.data.createWalletAddress.walletAddress.url, but the GraphQL selection set for walletAddress in this request does not include a url field (it includes address instead). In GraphQL, omitted fields won’t be present in the response, so this will be undefined and the included tests will fail. Align the selection set and the post-response mapping (either request url explicitly if it exists in the schema, or set walletAddressUrl from the selected address field / rename the env var accordingly).

Suggested change
bru.setEnvVar("walletAddressUrl", body.data.createWalletAddress.walletAddress.url);
bru.setEnvVar("walletAddressUrl", body.data.createWalletAddress.walletAddress.address);

Copilot uses AI. Check for mistakes.
variables: {
input: {
assetId: bru.getEnvVar("assetId"),
url: "https://" + bru.getEnvVar("OpenPaymentsHost") + "/simon/" + randomInt,
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The pre-request script builds the wallet address URL using bru.getEnvVar("OpenPaymentsHost"), but this env var isn’t defined anywhere in the repository’s Rafiki Bruno environments (only senderOpenPaymentsHost / receiverOpenPaymentsHost patterns are used elsewhere). This likely produces https://undefined/... URLs by default. Consider switching to an existing env var that is actually set in the collection flow (e.g., the sender Open Payments host) or adding OpenPaymentsHost to the committed environment templates/docs so the request is reproducible.

Suggested change
url: "https://" + bru.getEnvVar("OpenPaymentsHost") + "/simon/" + randomInt,
url: "https://" + bru.getEnvVar("senderOpenPaymentsHost") + "/simon/" + randomInt,

Copilot uses AI. Check for mistakes.
Comment on lines +92 to 95
const graphqlUrl = bru.getEnvVar("RafikiGraphqlHost") + "/graphql";
const response = await fetch(graphqlUrl, postRequest);
const body = await response.json();
bru.setEnvVar("secondWalletAddressId", body.data.createWalletAddress.walletAddress.id);
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The script assumes the wallet-address creation succeeded and immediately dereferences body.data.createWalletAddress.walletAddress.id. If the fetch fails (non-2xx) or the GraphQL response contains errors (no data), this will throw a TypeError and obscure the real failure. Add a check for response.ok and/or body?.data?.createWalletAddress (and surface body.errors in the thrown error) before setting secondWalletAddressId.

Copilot uses AI. Check for mistakes.
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.

Fix Create Quote GraphQL Request in Bruno Collection

2 participants