Skip to content

Demo Quality Kit #254

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Demo Quality Kit #254

wants to merge 1 commit into from

Conversation

vlussenburg
Copy link
Collaborator

@vlussenburg vlussenburg commented Jun 28, 2025

✨ PR Description

Purpose: Implement order history functionality and enhance frontend UX in the demo shop microservices application.

Main changes:

  • Added order history endpoint and persistence in OrderController with H2 database integration
  • Implemented getOrderHistory() function in frontend client with API endpoint integration
  • Added Swagger documentation to API endpoints using swagger-jsdoc and swagger-ui-express
  • Enhanced error handling in login flow and improved UI with structured CSS styling

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using. We'd love your feedback! 🚀

Copy link

gitstream-cm bot commented Jun 28, 2025

This PR affects one or more sensitive files and requires review from the security team.

Copy link

gitstream-cm bot commented Jun 28, 2025

🥷 Code experts: amitmohleji, b-sims

amitmohleji, b-sims have most 👩‍💻 activity in the files.
b-sims, amitmohleji have most 🧠 knowledge in the files.

See details

frontend/package.json

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR 8 additions & 0 deletions
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/public/app.js

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR 33 additions & 0 deletions
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/public/index.html

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR 20 additions & 0 deletions
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/server.js

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR 37 additions & 0 deletions
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

services/auth-python/app/auth.py

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:

services/billing-csharp/Controllers/BillingController.cs

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:

services/orders-java/pom.xml

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 54 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

services/orders-java/src/main/java/com/example/orders/controller/OrderController.java

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 75 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

services/orders-java/src/test/java/com/example/orders/OrdersApplicationTests.java

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 86 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

To learn more about /:\ gitStream - Visit our Docs

@gitstream-cm gitstream-cm bot requested review from amitmohleji and b-sims June 28, 2025 03:31
Copy link

@gitstream-cm gitstream-cm bot left a comment

Choose a reason for hiding this comment

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

✨ PR Review

The PR introduces order persistence functionality and UI improvements. The changes include database integration for order storage and history retrieval, but there are some significant issues with error handling and file operations that need attention.

3 issues detected:

🐞 Bug - Concurrent file access without synchronization can cause data corruption

Details: The file read/write operations in QueueForBillingSystemAsync are not thread-safe. Multiple concurrent requests could result in corrupted JSON files or lost billing data when attempting to read and write to the same user file simultaneously.
File: services/billing-csharp/Controllers/BillingController.cs (56-72)

🔒 Security - Stack trace exposure and lack of proper database constraints pose security risks

Details: While the code uses PreparedStatement which prevents basic SQL injection, the database initialization in the init() method creates a table without proper constraints or validation, and error handling exposes stack traces which could leak sensitive information.
File: services/orders-java/src/main/java/com/example/orders/controller/OrderController.java (75-75)

🐞 Bug - Silent exception handling can mask important errors and make debugging difficult

Details: The catch block in QueueForBillingSystemAsync silently ignores deserialization exceptions, which could mask important issues with corrupted billing data files and make debugging difficult.
File: services/billing-csharp/Controllers/BillingController.cs (68-68)

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using. We'd love your feedback! 🚀

Comment on lines +56 to +72
private async Task QueueForBillingSystemAsync(string username, object payload)
{
Directory.CreateDirectory(StorageDirectory);
var filePath = Path.Combine(StorageDirectory, $"{username}.json");
List<object> payloads = new();

if (System.IO.File.Exists(filePath))
{
try
{
payloads = JsonSerializer.Deserialize<List<object>>(await System.IO.File.ReadAllTextAsync(filePath)) ?? new();
}
catch { }
}

payloads.Add(payload);
await System.IO.File.WriteAllTextAsync(filePath, JsonSerializer.Serialize(payloads, new JsonSerializerOptions { WriteIndented = true }));
Copy link

Choose a reason for hiding this comment

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

🐞 Bug - File Concurrency Issue: Implement proper locking mechanism around file operations or use a thread-safe data structure/database for storing billing queue data instead of direct file manipulation.

Suggested change
private async Task QueueForBillingSystemAsync(string username, object payload)
{
Directory.CreateDirectory(StorageDirectory);
var filePath = Path.Combine(StorageDirectory, $"{username}.json");
List<object> payloads = new();
if (System.IO.File.Exists(filePath))
{
try
{
payloads = JsonSerializer.Deserialize<List<object>>(await System.IO.File.ReadAllTextAsync(filePath)) ?? new();
}
catch { }
}
payloads.Add(payload);
await System.IO.File.WriteAllTextAsync(filePath, JsonSerializer.Serialize(payloads, new JsonSerializerOptions { WriteIndented = true }));
private static readonly SemaphoreSlim FileLock = new(1, 1);
private async Task QueueForBillingSystemAsync(string username, object payload)
{
Directory.CreateDirectory(StorageDirectory);
var filePath = Path.Combine(StorageDirectory, $"{username}.json");
await FileLock.WaitAsync();
try
{
List<object> payloads = new();
if (System.IO.File.Exists(filePath))
{
try
{
payloads = JsonSerializer.Deserialize<List<object>>(await System.IO.File.ReadAllTextAsync(filePath)) ?? new();
}
catch { }
}
payloads.Add(payload);
await System.IO.File.WriteAllTextAsync(filePath, JsonSerializer.Serialize(payloads, new JsonSerializerOptions { WriteIndented = true }));
}
finally
{
FileLock.Release();
}

pstmt.setString(5, timestamp);
pstmt.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
Copy link

Choose a reason for hiding this comment

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

🔒 Security - SQL Injection Risk: Add proper database constraints, implement structured logging instead of printStackTrace(), and consider using proper database migration tools for schema initialization.

Suggested change
e.printStackTrace();
logger.error("Order storage failed for user: {}", username, e);

{
payloads = JsonSerializer.Deserialize<List<object>>(await System.IO.File.ReadAllTextAsync(filePath)) ?? new();
}
catch { }
Copy link

Choose a reason for hiding this comment

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

🐞 Bug - Silent Exception Handling: Add proper logging for exceptions and consider implementing file corruption recovery mechanisms or validation of the JSON structure before deserialization.

Suggested change
catch { }
catch (Exception ex)
{
// Log the exception and continue with empty list to avoid breaking the billing process
// TODO: Consider implementing file corruption recovery mechanisms
Console.WriteLine($"Warning: Failed to deserialize billing data for user {username}: {ex.Message}");
payloads = new();
}

Copy link

gitstream-cm bot commented Jun 28, 2025

This PR is missing a Jira ticket reference in the title or description.
Please add a Jira ticket reference to the title or description of this PR.

Copy link

gitstream-cm bot commented Jun 28, 2025

Hello vlussenburg 👋 Thanks for making your first PR, and welcome to our project!
Our mentor team has automatically been assigned to review this PR and guide you through the process.
Please reach out to that team if you have questions about the next steps.

Copy link

gitstream-cm bot commented Jun 28, 2025

🥷 Code experts: amitmohleji, b-sims

amitmohleji, b-sims have most 👩‍💻 activity in the files.
b-sims, amitmohleji have most 🧠 knowledge in the files.

See details

frontend/package.json

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR 8 additions & 0 deletions
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/public/app.js

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR 33 additions & 0 deletions
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/public/index.html

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR 20 additions & 0 deletions
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

frontend/server.js

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR 37 additions & 0 deletions
MAR
FEB
JAN

Knowledge based on git-blame:
amitmohleji: 100%

services/auth-python/app/auth.py

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:

services/billing-csharp/Controllers/BillingController.cs

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY
APR
MAR
FEB
JAN

Knowledge based on git-blame:

services/orders-java/pom.xml

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 54 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

services/orders-java/src/main/java/com/example/orders/controller/OrderController.java

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 75 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

services/orders-java/src/test/java/com/example/orders/OrdersApplicationTests.java

Activity based on git-commit:

amitmohleji b-sims
JUN
MAY 86 additions & 0 deletions
APR
MAR
FEB
JAN

Knowledge based on git-blame:
b-sims: 100%

To learn more about /:\ gitStream - Visit our Docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant