Skip to content

fix(behat): stop nested develop/pdf fetches causing cURL 52 flakes - #8430

Merged
vitormattos merged 10 commits into
LibreSign:mainfrom
lfals:fix/behat-curl-error-52
Sep 20, 2026
Merged

vitormattos merged 10 commits into
LibreSign:mainfrom
lfals:fix/behat-curl-error-52

Conversation

@lfals

@lfals lfals commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Resolves: #8422

📝 Summary

Behat fixtures used {"url":"<BASE_URL>/apps/libresign/develop/pdf"}, so each request-signature call nested an HTTP GET to the same PHP built-in server. Combined with experimental PHP_CLI_SERVER_WORKERS, that intermittently produced empty replies (cURL 52 / ConnectException), often followed by cURL 7 once the server stopped accepting connections—especially under burst load in file/list.feature.

This PR:

  • Adds <SMALL_VALID_PDF_BASE64> for fixtures that do not need to exercise URL download (inline small_valid.pdf)
  • Serves <SMALL_VALID_PDF_URL> from a separate local FixtureHttpServer so URL download stays covered in integration without nested self-HTTP on the Behat PHP server
  • Keeps Behat workers: 2 (single-worker deadlocks nested/self HTTP; high worker counts were flaky)
  • Does not retry failed HTTP requests (unsafe for POST such as request-signature, and hides the real failure)

Further diagnosis of PHP built-in server death belongs in libresign/behat-builtin-extension verbose mode (see LibreSign/behat-builtin-extension#76 → intended v0.6.4), then a tests/integration/composer.lock bump on this branch.

🧪 How to test

  1. Review the Behat harness commits on this branch (base64 fixtures → fixture HTTP server → workers → no request retry).
  2. Run a previously flaky scenario (or rely on Behat CI):
    cd tests/integration
    vendor/bin/behat features/file/list.feature:45
  3. Confirm URL coverage still works via <SMALL_VALID_PDF_URL> (scenario in request.feature).
  4. Confirm Behat CI jobs are green on this PR.
  5. After behat-builtin-extension v0.6.4 is published: bump tests/integration/composer.lock and re-run Behat CI with debug (-v / BEHAT_VERBOSE) to capture server PID/logs/exit status if flakes remain.

⚙️ API / Back‑end changes

  • No production API/service behavior changes — Behat test harness only
  • Integration fixtures updated; URL download still covered (fixture server + unit tests such as FileContentProviderTest)
  • Capabilities updated (if applicable) – N/A
  • Documentation updated (if applicable) - N/A
  • API documentation updated with the command composer openapi if necessary – N/A

🚧 Tasks

✅ Checklist

  • I have read and followed the contribution guide.
  • Changes focus on removing nested self-HTTP and keeping URL coverage via a separate fixture server
  • No unsafe POST retry workaround
  • DCO sign-off on commits

🤖 AI (if applicable)

  • The content of this PR was partially or fully generated using AI

@lfals
lfals requested a review from a team as a code owner September 18, 2026 14:28
@github-project-automation github-project-automation Bot moved this to 0. Backlog in LibreSign Roadmap Sep 18, 2026
@lfals
lfals force-pushed the fix/behat-curl-error-52 branch from 2418b8c to df0cd2c Compare September 18, 2026 14:29
@lfals
lfals marked this pull request as draft September 18, 2026 14:30

@vitormattos vitormattos 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.

I agree with avoiding the request to the same PHP server here, but changing all URL fixtures to base64 means we will not have integration coverage for the url file source anymore.

FileContentProviderTest covers the service itself, but it does not verify that request-signature still accepts a {"url": ...} payload and correctly passes it to the file content provider.

Could we keep at least one integration test for the URL flow, using a fixture served by another local HTTP server instead of the same Behat PHP server?

@github-project-automation github-project-automation Bot moved this from 0. Backlog to 1. to do in LibreSign Roadmap Sep 18, 2026
Comment thread tests/integration/features/bootstrap/FeatureContext.php Outdated
@lfals
lfals force-pushed the fix/behat-curl-error-52 branch from 4e83f73 to dba2e74 Compare September 18, 2026 17:38
@vitormattos

Copy link
Copy Markdown
Member

I reran the failing Behat job with debug logging enabled to get more information from the PHP built-in server.

Let's wait for this run and check if it gives us more details about the cURL 52 failure.

@vitormattos

Copy link
Copy Markdown
Member

The last changes are starting to work around the failure instead of helping us understand it.

The retry does not solve the problem. In the last CI run, after the first cURL 52, the next requests start failing with cURL 7: Couldn't connect to server. Also, retrying POST requests such as request-signature is not safe because we don't know if the first request was already processed.

Please remove TransientConnectionRetry and let's improve the diagnostics in the right place instead.

The PHP server is started by LibreSign/behat-builtin-extension, in src/RunServerListener.php. This package already has a verbose mode, but it does not give us enough information when the server process stops during the suite.

I suggest improving the verbose mode there so it permanently reports useful process information, including:

  • PID, host, port and worker count when the server starts;
  • PHP built-in server stdout/stderr;
  • process exit status when the server terminates;
  • a clear message when teardown finds that the server process is already gone, instead of only kill: No such process.

Please add tests for this behavior in behat-builtin-extension too.

After this is merged, we can create a new behat-builtin-extension patch release, probably v0.6.4. nextcloud-behat already accepts ^0.6.3, so we should not need a change there just to consume v0.6.4.

Then we can update tests/integration/composer.lock in this PR to use the new release and rerun the failing Behat CI with debug enabled.

At that point we should have better evidence about why the PHP server stops responding, instead of adding more workarounds here.

@lfals

lfals commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Please add tests for this behavior in behat-builtin-extension too.

After this is merged, we can create a new behat-builtin-extension patch release, probably v0.6.4. nextcloud-behat already accepts ^0.6.3, so we should not need a change there just to consume v0.6.4.

@vitormattos
I've done the changes in the behat-builtin-extension, PR at LibreSign/behat-builtin-extension#76

Provide an inline data-URI from small_valid.pdf so scenarios can send
PDFs without nested HTTP to the PHP built-in server.

Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Avoid request-signature downloading from the same Behat PHP server,
which required multi-worker mode and caused cURL 52 empty-reply flakes.

Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
With fixtures no longer nesting HTTP to develop/pdf, a single-process
php -S is enough and avoids experimental PHP_CLI_SERVER_WORKERS flakes.

Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
workers: 0 deadlocks any nested self-HTTP on php -S. Use the minimum
of two workers while fixtures stay on inline PDF base64 to avoid the
previous cURL 52 flakes from workers: 10.

Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Serve small_valid.pdf from a second local php -S process and add a
scenario that posts {"url":"<PDF_URL>"} so url download stays covered
without nested HTTP to the Behat Nextcloud server.

Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Use SMALL_VALID_PDF_BASE64 / getSmallValidPdfBase64() (and matching URL
names) so future fixtures can be added without ambiguous placeholders.

Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Failsafe for residual cURL 52 empty-reply flakes during Behat HTTP
bursts; retries up to three times with backoff and STDERR diagnostics.

Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
Retrying around cURL 52/7 hides the real failure and is unsafe for POST
requests such as request-signature. Prefer diagnosing PHP built-in
server death via behat-builtin-extension verbose mode.

Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
@lfals
lfals force-pushed the fix/behat-curl-error-52 branch from c201e74 to 061c454 Compare September 19, 2026 02:18
@vitormattos

vitormattos commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

https://github.com/LibreSign/behat-builtin-extension/releases/tag/v0.7.0 🥳

@lfals

lfals commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@vitormattos following the original plan: nextcloud-behat still requires libresign/behat-builtin-extension: ^0.6.3, so consumers cannot pick up v0.7.0 without a constraint change or an inline alias.

Could you also tag v0.6.4 on the same commit as v0.7.0? After that I can bump tests/integration/composer.lock

@vitormattos

Copy link
Copy Markdown
Member

nextcloud-behat still requires libresign/behat-builtin-extension: ^0.6.3

Started the process here: LibreSign/nextcloud-behat#112
Waiting the CI

@vitormattos

Copy link
Copy Markdown
Member

Unlock verbose PHP built-in server diagnostics so Behat CI can show PID, logs, and exit status on cURL 52 flakes.

Signed-off-by: Luis Amorim <luisfelipeamorim@hotmail.com>
@vitormattos

Copy link
Copy Markdown
Member

I’ll wait for the current CI run to finish first.

After that, I’m going to rerun the Behat SQLite job SQLite PHP 8.3 Nextcloud master with debug logging enabled.

Now that this branch is using nextcloud-behat v1.6.1 and behat-builtin-extension v0.7.0, that run should give us the new PHP built-in server diagnostics if the cURL 52 problem happens again.

@vitormattos vitormattos 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.

Well... now everything passed 😅

Maybe the issue was really intermittent, or maybe one of the changes in behat-builtin-extension / nextcloud-behat fixed what was triggering it.

Since the full CI is green now, I think we can move forward. If cURL 52 comes back, at least now we have much better diagnostics to understand what happened.

@vitormattos

vitormattos commented Sep 20, 2026 •

Copy link
Copy Markdown
Member

Can I go ahead and merge this? I think that we also can make backport to stable branches >= 33
If yes, make this as ready for review.

@lfals

lfals commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

Well... now everything passed 😅

Maybe the issue was really intermittent, or maybe one of the changes in behat-builtin-extension / nextcloud-behat fixed what was triggering it.

Since the full CI is green now, I think we can move forward. If cURL 52 comes back, at least now we have much better diagnostics to understand what happened.

we can observe the upcoming CIs

@lfals
lfals marked this pull request as ready for review September 20, 2026 19:48
@lfals

lfals commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

Can I go ahead and merge this? I think that we also can make backport to stable branches >= 33 If yes, make this as ready for review.

Go for it 😎

@vitormattos
vitormattos merged commit ad43787 into LibreSign:main Sep 20, 2026
68 checks passed
@vitormattos

Copy link
Copy Markdown
Member

/backport to stable35

@vitormattos

Copy link
Copy Markdown
Member

/backport to stable34

@backportbot-libresign backportbot-libresign Bot added the backport-request Request to backport a change to supported stable branches label Sep 20, 2026
@lfals
lfals deleted the fix/behat-curl-error-52 branch September 20, 2026 19:52
@vitormattos

Copy link
Copy Markdown
Member

/backport to stable33

@backportbot-libresign backportbot-libresign Bot removed the backport-request Request to backport a change to supported stable branches label Sep 20, 2026
vitormattos added a commit that referenced this pull request Sep 20, 2026
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
vitormattos added a commit that referenced this pull request Sep 20, 2026
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
vitormattos added a commit that referenced this pull request Sep 20, 2026
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

ci(behat): flake cURL error 52 Empty reply from server on request-signature

2 participants