Skip to content

Conversation

@lohanidamodar
Copy link
Contributor

@lohanidamodar lohanidamodar commented Jun 30, 2025

Fix route matching when path is null

Summary by CodeRabbit

  • New Features

    • Added support for response compression, configurable via new methods and environment settings.
    • Introduced telemetry instrumentation for request metrics.
    • Added a validator that accepts values matching any of multiple rules.
    • Enhanced route handling to better manage malformed or missing paths, defaulting to the root route as needed.
    • Expanded HTTP status code support to include "451 Unavailable For Legal Reasons."
    • New endpoints for deployment and collection management, and early response handling.
  • Bug Fixes

    • Improved error handling robustness, especially when error handlers themselves fail.
    • Enhanced route parameter resolution and aliasing.
  • Documentation

    • Updated minimum PHP version requirement to 8.1 in documentation.
  • Tests

    • Added comprehensive tests for compression, telemetry, route matching edge cases, error handler failures, and new validator behaviors.
    • Expanded end-to-end tests for new endpoints and fallback routing.
  • Chores

    • Updated PHP version requirements and Docker images to 8.1.
    • Improved workflow consistency and container environments in CI configurations.
    • Minor formatting and code style adjustments.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 30, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This update introduces telemetry and compression support to the application core, adds a new AnyOf validator, and enhances error handling and route matching. The PHP and Composer versions are raised to 8.1 and 2.6, respectively. Numerous new tests are added to cover edge cases, compression, and validator logic, and documentation is updated accordingly.

Changes

File(s) Change Summary
.github/workflows/bench.yml, .github/workflows/codeql-analysis.yml Pin Composer Docker image to version 2.6 for workflow jobs.
.github/workflows/test.yml, Dockerfile Update PHP version from 8.0 to 8.1; switch to docker compose syntax.
README.md Raise documented minimum PHP version to 8.1.
composer.json Require PHP 8.1, add utopia-php/compression and utopia-php/telemetry, disallow certain plugins.
src/App.php Add telemetry and compression support, improve error handling, route matching, and argument resolution.
src/Hook.php Add $deprecated parameter to param method.
src/Response.php Add HTTP 451, implement response compression, expand compressible MIME types, add related setters.
src/Route.php Change pathParams to nested array, add matchedPath property and accessors, update parameter methods.
src/Router.php Pass matched/alias paths to routes, make preparePath public.
src/Validator/AnyOf.php Add new AnyOf validator class for composite validation.
src/Validator/Host.php Delegate host whitelist validation to Hostname validator.
src/Validator/ArrayList.php Minor formatting fix in getDescription.
tests/AppTest.php Add tests for resource defaults as functions, route matching edge cases, and error handler failures.
tests/ResponseTest.php, tests/ViewTest.php Minor formatting fixes in catch blocks.
tests/Validator/DomainTest.php, tests/Validator/IPTest.php, tests/Validator/URLTest.php Add blank lines after opening PHP tag.
tests/Validator/HostTest.php Add wildcard domain tests for Host validator.
tests/Validator/MultipleOfTest.php Add new test class for AnyOf validator.
tests/e2e/Client.php Improve request body encoding and Accept-Encoding handling.
tests/e2e/ResponseTest.php Add tests for early response, null/malformed path, root fallback, and alias with parameter.
tests/e2e/server.php Add endpoints for deployment, collections, early response; enable compression in app.

Sequence Diagram(s)

Telemetry and Compression in App Run

sequenceDiagram
    participant Client
    participant App
    participant Telemetry
    participant Response

    Client->>App: Sends HTTP Request
    App->>Telemetry: Increment activeRequests
    App->>Telemetry: Start requestDuration timer
    App->>App: runInternal(request, response)
    App->>Response: Configure compression if enabled
    App->>Telemetry: Record requestBodySize
    App->>App: Route matching, execution, error handling
    App->>Telemetry: Stop requestDuration timer, record duration
    App->>Telemetry: Decrement activeRequests
    App->>Telemetry: Record responseBodySize
    App->>Response: Send response
    Response->>Client: Return HTTP Response
Loading

Response Compression Logic

sequenceDiagram
    participant App
    participant Response
    participant Client

    App->>Response: Set Accept-Encoding, Compression Min Size, Supported Algorithms
    App->>Response: Prepare response body
    Response->>Client: Check Accept-Encoding, Content-Type, Body Size
    alt Compressible and Acceptable
        Response->>Response: Compress body, set headers
    end
    Response->>Client: Send (possibly compressed) response
Loading

Poem

🐇
New features hop in, swift and bright,
Telemetry tracks each server flight.
Compression squeezes bytes so tight,
Routing’s sharper, error paths light.
Validators gather, wildcards play,
With PHP 8.1, we leap today!
—A rabbit coding on a sunny day.


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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@lohanidamodar lohanidamodar changed the base branch from master to 0.33.x June 30, 2025 09:26
* @return string|null
*/
public static function getEnv(string $key, string $default = null): ?string
public static function getEnv(string $key, ?string $default = null): ?string
Copy link
Contributor

Choose a reason for hiding this comment

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

@lohanidamodar lohanidamodar merged commit c2203e8 into 0.33.x Jul 6, 2025
5 checks passed
@lohanidamodar lohanidamodar deleted the fix-null-path branch July 7, 2025 09:38
@coderabbitai coderabbitai bot mentioned this pull request Oct 12, 2025
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.

3 participants