Skip to content

fix(tool): modify list schema to use SchemaRegistryClient to be accessible for CP #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 15, 2025

Conversation

eddyv
Copy link
Member

@eddyv eddyv commented May 14, 2025

This pull request refactors the ListSchemasHandler to improve its functionality, logging, and error handling. Key updates include replacing the use of wrapAsPathBasedClient with the SchemaRegistryClient, enhancing logging for better debugging, and restructuring the logic to fetch schemas and their metadata.

Refactoring and functionality improvements:

  • Replaced wrapAsPathBasedClient with SchemaRegistryClient for interacting with the Schema Registry, allowing more granular control over schema operations. [1] [2]
  • Updated the deleted argument to use a boolean type with a default value of false for better clarity and type safety.

Logging enhancements:

  • Added detailed logger.debug, logger.info, and logger.warn statements to trace the flow of execution, log key operations, and capture errors during schema fetching and filtering.

Error handling improvements:

  • Enhanced error handling for schema metadata retrieval, including logging specific errors for failed operations and returning error details in the response.

Minor updates:

  • Changed the default value for the baseUrl argument to use a function, ensuring it dynamically evaluates the environment variable.

eddyv added 3 commits May 14, 2025 14:22
… and logging

- Integrated SchemaRegistryClient for fetching schema subjects and metadata.
- Updated argument validation to include a boolean for deleted schemas.
- Enhanced logging to provide detailed debug information during schema retrieval.
- Improved error handling for fetching schema metadata and versions, ensuring clearer error messages in responses.
…equired environment variables

- Eliminated the baseUrl argument from the ListSchemasHandler, simplifying the argument structure.
- Updated the getRequiredEnvVars method to include SCHEMA_REGISTRY_ENDPOINT as a necessary environment variable, enhancing configuration management.
@eddyv eddyv marked this pull request as ready for review May 15, 2025 12:59
@Copilot Copilot AI review requested due to automatic review settings May 15, 2025 12:59
@eddyv eddyv requested a review from a team as a code owner May 15, 2025 12:59
@eddyv eddyv enabled auto-merge (squash) May 15, 2025 12:59
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the ListSchemasHandler to replace the previous path-based client implementation with SchemaRegistryClient, update the argument types, and improve logging and error handling for schema listing operations.

  • Replaced wrapAsPathBasedClient with SchemaRegistryClient for schema operations
  • Changed the deleted argument from a string to a boolean type with a default value of false
  • Improved logging and error handling while restructuring the schema fetching logic

const versions: number[] = await registry.getAllVersions(subject);
logger.debug({ subject, versions }, "Fetched all schema versions");
result[subject] = [];
for (const version of versions) {
Copy link
Preview

Copilot AI May 15, 2025

Choose a reason for hiding this comment

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

The schema metadata fetching within the for-loop is done sequentially, which could lead to performance bottlenecks. Consider parallelizing these calls using Promise.all to reduce latency.

Suggested change
for (const version of versions) {
const versionPromises = versions.map(async (version) => {

Copilot uses AI. Check for mistakes.

Copy link
Member

@bhughes20 bhughes20 left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@eddyv eddyv merged commit b5aa4ea into main May 15, 2025
1 of 2 checks passed
@eddyv eddyv deleted the fix/list-schema-tool branch May 15, 2025 14:15
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.

2 participants