Skip to content

fix: consistent http repsonses#2523

Merged
robfrank merged 2 commits intoArcadeData:mainfrom
gramian:main
Sep 16, 2025
Merged

fix: consistent http repsonses#2523
robfrank merged 2 commits intoArcadeData:mainfrom
gramian:main

Conversation

@gramian
Copy link
Collaborator

@gramian gramian commented Sep 15, 2025

What does this PR do?

This change:

  • removes the createResult method in the AbstractHttpServerHandler class as it is now unneeded.
  • adds server name and server version to the responses of the /server GET query (which was before done via createResult
  • removes meta information from the /server POST commands
  • removes meta information from the /databases GET query

Motivation

I observed differing contents in HTTP responses in terms of non-result content.

Related issues

#2398

Additional Notes

I will be updating the docs accordingly

Checklist

  • I have run the build using mvn clean package command
  • My unit tests cover both failure and success scenarios

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @gramian, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an observed inconsistency in HTTP responses by standardizing their content. The primary goal is to ensure that API responses are predictable and contain only the necessary information. This is achieved by removing a redundant utility method, directly embedding server details where appropriate, and stripping unnecessary meta-information from specific API endpoints, thus improving the overall clarity and consistency of the server's HTTP output.

Highlights

  • Removed Redundant Method: The createResult method in AbstractHttpServerHandler has been removed as it is no longer needed, simplifying the codebase.
  • Enhanced /server GET Response: The /server GET query now explicitly includes the server name and server version directly in its responses, providing essential server information.
  • Streamlined /server POST Responses: Meta information has been removed from the responses of /server POST commands, leading to cleaner and more focused output.
  • Simplified databases GET Query: Meta information has also been removed from the responses of the databases GET query, ensuring consistency with other API endpoints.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aims to create more consistent HTTP responses by selectively including or removing metadata. The createResult helper method is removed, and its call sites are updated to either remove the metadata or explicitly add only the necessary fields. The changes correctly implement the described behavior and improve API consistency. My review includes a few suggestions to improve code readability by removing redundant parentheses in JSONObject instantiations.

installedDatabases.retainAll(allowedDatabases);

final JSONObject result = createResult(user, null).put("result", new JSONArray(installedDatabases));
final JSONObject response = (new JSONObject()).put("result", new JSONArray(installedDatabases));
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The parentheses around new JSONObject() are redundant and can be removed to improve code clarity. The line can be simplified to new JSONObject().put(...).

Suggested change
final JSONObject response = (new JSONObject()).put("result", new JSONArray(installedDatabases));
final JSONObject response = new JSONObject().put("result", new JSONArray(installedDatabases));

Comment on lines +49 to +50
final JSONObject response = (new JSONObject()).put("version", Constants.getVersion())
.put("serverName", httpServer.getServer().getServerName());
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The parentheses around new JSONObject() are redundant and can be removed to improve code clarity. The instantiation can be simplified to new JSONObject().put(...).

Suggested change
final JSONObject response = (new JSONObject()).put("version", Constants.getVersion())
.put("serverName", httpServer.getServer().getServerName());
final JSONObject response = new JSONObject().put("version", Constants.getVersion())
.put("serverName", httpServer.getServer().getServerName());

installedDatabases.retainAll(allowedDatabases);

final JSONObject response = createResult(user, null).put("result", new JSONArray(installedDatabases));
final JSONObject response = (new JSONObject()).put("result", new JSONArray(installedDatabases));
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The parentheses around new JSONObject() are redundant and can be removed to improve code clarity. The line can be simplified to new JSONObject().put(...).

Suggested change
final JSONObject response = (new JSONObject()).put("result", new JSONArray(installedDatabases));
final JSONObject response = new JSONObject().put("result", new JSONArray(installedDatabases));

@robfrank robfrank added this to the 25.9.1 milestone Sep 16, 2025
@robfrank robfrank added the enhancement New feature or request label Sep 16, 2025
@robfrank robfrank merged commit 1df409f into ArcadeData:main Sep 16, 2025
8 of 12 checks passed
@robfrank robfrank linked an issue Sep 16, 2025 that may be closed by this pull request
robfrank pushed a commit that referenced this pull request Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HTTP-API] Inconsistent responses among endpoints

2 participants