Skip to content

Conversation

@megatnt1122
Copy link
Collaborator

@megatnt1122 megatnt1122 commented Dec 16, 2025

Ticket

#1522

Description

Small Fixes to the Query Router

Tasks

  • - A description of the PR has been provided, and a diagram included if it is a new feature.
  • - Formatter has been run
  • - CHANGELOG comment has been added
  • - Labels have been assigned to the pr
  • - A reviwer has been added
  • - A user has been assigned to work on the pr
  • - If new feature a unit test has been added

Summary by Sourcery

Enhancements:

  • Log only the result count instead of full result payload for direct published data search executions in both success and failure cases to reduce log volume and exposure.

@megatnt1122 megatnt1122 self-assigned this Dec 16, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Dec 16, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the query router request logging for the direct execution endpoint to log only a summary (result count) instead of the full results payload on both success and failure paths.

Sequence diagram for updated logging in exec_direct query router endpoint

sequenceDiagram
    actor Client
    participant QueryRouter
    participant SearchService
    participant Logger

    Client->>QueryRouter: POST /exec/direct
    QueryRouter->>SearchService: executeSearchQuery(payload)
    alt Success
        SearchService-->>QueryRouter: results
        QueryRouter->>Logger: logRequestSuccess(routePath=/exec/direct, extra={count})
        Logger-->>QueryRouter: logged
        QueryRouter-->>Client: 200 OK with results
    else Failure
        SearchService-->>QueryRouter: throw error e (optional partial results)
        QueryRouter->>Logger: logRequestFailure(routePath=/exec/direct, extra={count}, error=e)
        Logger-->>QueryRouter: logged
        QueryRouter-->>Client: error response
    end
Loading

Flow diagram for computing extra count for query router logging

flowchart TD
    A[Receive results from search execution] --> B{results is Array?}
    B -- Yes --> C[Set count to results.length]
    B -- No --> D[Set count to undefined]
    C --> E[Build extra object with count]
    D --> E[Build extra object with count]
    E --> F{Success or Failure?}
    F -- Success --> G[Call logRequestSuccess with extra]
    F -- Failure --> H[Call logRequestFailure with extra and error]
Loading

File-Level Changes

Change Details Files
Log only a summary of query results (count) instead of the full results object for direct execution requests in both success and failure logging.
  • Wrap the logger success call's extra field in an object containing count derived from results when it is an array, otherwise undefined.
  • Apply the same extra field structure and count logic to the logger failure call to keep success and failure logging consistent.
core/database/foxx/api/query_router.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@megatnt1122 megatnt1122 added Type: Refactor Imlplementation change, same functionality Priority: Low Lower priority work. Component: Foxx Foxx Arango micro services. labels Dec 16, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • In the failure path, results may be undefined if an exception is thrown before it is assigned; consider initializing results (e.g., to [] or null) before the try so the count calculation is predictable in both success and failure cases.
  • The extra: { count: ... } logic is duplicated in both the success and failure logging calls; consider extracting a small helper (e.g., getResultCount(results)) to avoid repeating the same expression and keep the behavior consistent if it changes later.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In the failure path, `results` may be undefined if an exception is thrown before it is assigned; consider initializing `results` (e.g., to `[]` or `null`) before the `try` so the `count` calculation is predictable in both success and failure cases.
- The `extra: { count: ... }` logic is duplicated in both the success and failure logging calls; consider extracting a small helper (e.g., `getResultCount(results)`) to avoid repeating the same expression and keep the behavior consistent if it changes later.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@JoshuaSBrown
Copy link
Collaborator

Please add tests for this:

qry/exec/direct

so we can make sure it is displaying correctly in the logs.

@JoshuaSBrown JoshuaSBrown removed their assignment Dec 16, 2025
@megatnt1122 megatnt1122 merged commit 957db8e into devel Jan 21, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Foxx Foxx Arango micro services. Priority: Low Lower priority work. Type: Refactor Imlplementation change, same functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants