Skip to content

Fix duplicate header issue for Swoole 6.1.6 compatibility#144

Merged
abnegate merged 1 commit intomainfrom
fix-headers
Feb 5, 2026
Merged

Fix duplicate header issue for Swoole 6.1.6 compatibility#144
abnegate merged 1 commit intomainfrom
fix-headers

Conversation

@abnegate
Copy link
Member

@abnegate abnegate commented Feb 5, 2026

Swoole 6.1.3+ stores duplicate HTTP headers as arrays instead of using last-value-wins. This caused issues when:

  1. The SDK's addHeader() lowercases header keys (x-appwrite-project)
  2. But importFile() was passing mixed-case headers (X-Appwrite-Project)
  3. array_merge() kept both keys since PHP arrays are case-sensitive
  4. Swoole then stored both as arrays, causing type errors

Fixes:

  • Destinations/Appwrite.php: Remove redundant auth headers from importFile() - they're already set via setProject()/setKey()
  • Sources/Appwrite.php: Use lowercase header keys for consistency with the SDK's addHeader() method

Summary by CodeRabbit

  • Refactor
    • Simplified authentication header handling for Appwrite file operations
    • Standardized HTTP header key formatting to lowercase across Appwrite integration

Swoole 6.1.3+ stores duplicate HTTP headers as arrays instead of
using last-value-wins. This caused issues when:

1. The SDK's addHeader() lowercases header keys (x-appwrite-project)
2. But importFile() was passing mixed-case headers (X-Appwrite-Project)
3. array_merge() kept both keys since PHP arrays are case-sensitive
4. Swoole then stored both as arrays, causing type errors

Fixes:
- Destinations/Appwrite.php: Remove redundant auth headers from
  importFile() - they're already set via setProject()/setKey()
- Sources/Appwrite.php: Use lowercase header keys for consistency
  with the SDK's addHeader() method

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

Walkthrough

Two files in the Appwrite migration module were modified. The Destinations file had authentication headers removed from file upload requests (both single-part and multi-part upload paths). The Sources file had authentication header keys updated from mixed-case to lowercase format in the constructor and health/version API request. These changes shift authentication responsibility to Client configuration rather than per-request headers.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The linked issue #39 is about disabling document cache, which is unrelated to the header fixes for Swoole compatibility in this PR. Verify the linked issue is correct. If #39 is incorrect, link the appropriate issue describing the Swoole 6.1.6 header duplication problem.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing a header compatibility issue with Swoole 6.1.6 by removing duplicate headers.
Out of Scope Changes check ✅ Passed All changes are focused on fixing Swoole header compatibility: removing redundant auth headers from Destinations and standardizing header keys in Sources.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-headers

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 and usage tips.

abnegate added a commit to appwrite/appwrite that referenced this pull request Feb 5, 2026
Swoole 6.1+ stores duplicate HTTP headers as arrays instead of
using last-value-wins. While the root cause (duplicate headers in
the migration library) is fixed in:
utopia-php/migration#144

This defensive handling is needed until that PR is merged and a
new version of the migration library is released and adopted.

The handling takes the first value from the array if multiple
values are present, maintaining backward compatibility.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@abnegate abnegate merged commit b5fe198 into main Feb 5, 2026
4 checks passed
@abnegate abnegate deleted the fix-headers branch February 5, 2026 11:32
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.

1 participant