Skip to content

Fixing the lexical error Hello-world test#2509

Merged
hash-d merged 1 commit into
skupperproject:mainfrom
ramdrvcs:main
Jul 6, 2026
Merged

Fixing the lexical error Hello-world test#2509
hash-d merged 1 commit into
skupperproject:mainfrom
ramdrvcs:main

Conversation

@ramdrvcs

@ramdrvcs ramdrvcs commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

While I was running the E2E tests, I had the follwing error for hello-world module.

fatal: [west]: FAILED! => {"attempts": 30, "changed": true, "msg": "Task failed: Action failed: Unknown error.", "rc": 1, "return_code": 1, 
"stderr": "cannot parse the data: `lexical error: invalid character inside string.\n
{\"user\":{\"uid\":0,\"gid\":0,\"addi\n                     (right here) ------^\n`\n",
"stderr_lines": ["cannot parse the data: `lexical error: invalid character inside string.", " 
{\"user\":{\"uid\":0,\"gid\":0,\"addi", "                     (right here) ------^", "`"], 
"stdout": "", "stdout_lines": []}

Description

Fixes a critical runtime failure in the run_curl role where the task fails with an Unknown error (lexical error: invalid character inside string).

The failure occurs because ansible task definition contain end of line character in sh location. As of now it has been noticed in s390x.

Changes

Key Changes

  • Single Network Call (curl -s -w "\n%{http_code}" "{{ run_curl_address }}"): Reduces traffic by making exactly one request to the backend. The API response text is captured alongside the 3-digit HTTP status code, which is appended to a brand-new line at the very bottom.
  • Local Code Extraction (tail -n 1): Pipes the combined response string and isolates only the final line to extract the HTTP status code.
  • Local Body Preservation (sed "$ d"): Trims the appended status code line from the stream, safely preserving the original API message body (including any native trailing text or newlines).
  • Defensive String Evaluation ([ "$code" = "200" ]): Switches the conditional check to a robust string comparison. This protects the shell executor from crashing if network drops cause the status code to return empty.
  • Clean YAML Syntax: Formatted using the folded block scalar (>) to preserve intended script indentation and readability without breaking the Kubernetes command processor array.

Testing Triaged

  • Verified that payloads containing nested JSON quotes no longer trigger a lexical error.
  • Confirmed that the loop correctly runs exactly one HTTP request per retry iteration.
  • Confirmed the task successfully completed.

Summary by CodeRabbit

  • Bug Fixes
    • Improved end-to-end curl output handling by capturing both the response body and HTTP status code from a single curl execution.
    • Updated the role’s output formatting to reliably extract the status code and present results consistently as BODY: <body> on success and on failure.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The run_curl role now makes one curl request, splits the combined output into body and HTTP status code, and formats the result based on whether the code is 200.

Changes

run_curl response parsing

Layer / File(s) Summary
single curl output split
tests/e2e/collections/ansible_collections/e2e/tests/roles/run_curl/tasks/main.yml
A single curl call appends the HTTP code to the response, the task extracts code and body from that combined output, checks for "200", and prints either BODY: ... or `ERROR CODE: ...

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is clearly related to the main change: fixing the hello-world E2E lexical parsing error.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ramdrvcs ramdrvcs marked this pull request as ready for review June 24, 2026 09:24

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4fabd917-9871-463f-91d8-71e5570d176b

📥 Commits

Reviewing files that changed from the base of the PR and between 6f4f2b3 and 466bb5c.

📒 Files selected for processing (1)
  • tests/e2e/collections/ansible_collections/e2e/tests/roles/run_curl/tasks/main.yml

Comment thread tests/e2e/collections/ansible_collections/e2e/tests/roles/run_curl/tasks/main.yml Outdated
@ramdrvcs ramdrvcs force-pushed the main branch 2 times, most recently from 4b694b7 to e654414 Compare June 24, 2026 10:21
@ramdrvcs ramdrvcs marked this pull request as draft June 24, 2026 12:39
@ramdrvcs ramdrvcs marked this pull request as ready for review June 24, 2026 12:39
@hash-d hash-d requested review from granzoto and hash-d June 24, 2026 12:52

@hash-d hash-d left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ramdrvcs, I see the move to single curl call as a clear improvement. However, I'm not so sure about the base64 encoding. Please check my comments and let me know what you're seeing.

echo "BODY_BASE64: $response";
exit 0;
else
echo "BODY_BASE64: $response";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Picky: only the exit 0 / exit 1 needs to be within the if/else clauses. Move the echo to before the if, as it is identical in both cases.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have not changed the if/else block much here. I am leaving the original way as it is.

fi
'
tmp_file=$(mktemp);
code=$(curl -s -w "%{http_code}" -o "$tmp_file" "{{ run_curl_address }}");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I like the single call to curl. That's a good improvement.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks

'
tmp_file=$(mktemp);
code=$(curl -s -w "%{http_code}" -o "$tmp_file" "{{ run_curl_address }}");
response=$(base64 < "$tmp_file" | tr -d "\n");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is the crux of the PR, but I'm not convinced it is really required. The PR description mentions nested double quotes, but I see no nesting in the provided example.

Also, the contents of the example don't seem to match what I'd expect as a response from the backend service (it contanis user information in a json, whereas I'd expect a plain message such as Hello, stranger. I am Supreme Cipher (1360c152dd3c).).

Which task is throwing that error? Is it really failing on a curl call?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is corrected without base64

- name: Debug the curl command output
ansible.builtin.debug:
msg: "{{ curl_result.stdout }}"
msg: "{{ (curl_result.stdout | regex_search('BODY_BASE64: (.*)', '\\1') | first) | b64decode }}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is the only place where you're decoding it from base64. Is run_curl used elsewhere? Could other tests depend / parse the actual output. If so, they'd need to do the decoding, too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is corrected without base64

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 97126738-8060-4333-8e5b-e36378fe907c

📥 Commits

Reviewing files that changed from the base of the PR and between e654414 and 546374f.

📒 Files selected for processing (1)
  • tests/e2e/collections/ansible_collections/e2e/tests/roles/run_curl/tasks/main.yml

@ramdrvcs ramdrvcs requested a review from hash-d July 6, 2026 16:55

@hash-d hash-d left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm; I worked with Ram and the full suite still runs fine after the changes.

kubeconfig: "{{ kubeconfig }}"
pod: curl
command: >-
command: >

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Apparently, this is the main thing that fixes this issue, though we're not sure what the mechanism for that is

exit 1;
fi
response=$(curl -s -w "\n%{http_code}" "{{ run_curl_address }}");
code=$(echo "$response" | tail -n 1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Having a single call to curl is definitely an improvement, and not using a tmpfile for that is good, too.

@hash-d hash-d merged commit bb3c383 into skupperproject:main Jul 6, 2026
3 checks passed
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.

2 participants