Skip to content

Demo Base Kit #168

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 Base Kit #168

wants to merge 1 commit into from

Conversation

vlussenburg
Copy link
Collaborator

@vlussenburg vlussenburg commented Jun 7, 2025

✨ PR Description

Purpose and impact: This PR enhances the e-commerce application by adding order history functionality and improving the user interface.

Main changes:

  • Added order history retrieval in the backend and frontend
  • Implemented Swagger documentation for API endpoints
  • Updated UI with improved styling and a product dropdown menu

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 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 database persistence, order history functionality, and UI improvements. While the overall implementation is functional, there are several critical security and performance issues that need to be addressed.

3 issues detected:

🔒 Security - Concurrent file operations without synchronization can corrupt billing data

Details: The QueueForBillingSystemAsync method performs non-atomic read-modify-write operations on files without proper synchronization. Multiple concurrent requests for the same user could lead to data corruption or lost billing records.
File: services/billing-csharp/Controllers/BillingController.cs (62-72)

🔒 Security - Database schema creation uses inline SQL which could become a security risk

Details: While prepared statements are used correctly for parameterized queries, the table creation in the init method uses string concatenation. Although currently safe, this pattern could be problematic if schema modifications are made later.
File: services/orders-java/src/main/java/com/example/orders/controller/OrderController.java (28-32)

🧹 Maintainability - Generic exception handling with printStackTrace provides poor observability

Details: Database operations use generic exception catching with only printStackTrace() for logging. This provides no meaningful error information to operators and could expose sensitive details in logs.
File: services/orders-java/src/main/java/com/example/orders/controller/OrderController.java (74-75)

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 +62 to +72
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.

🔒 Security - File System Race Condition: Implement file-level locking using FileStream with FileShare.None or use a proper database/queue system for billing data persistence.

Suggested change
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 }));
using (var fileStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None))
{
if (fileStream.Length > 0)
{
try
{
fileStream.Seek(0, SeekOrigin.Begin);
payloads = await JsonSerializer.DeserializeAsync<List<object>>(fileStream) ?? new();
}
catch { }
}
payloads.Add(payload);
fileStream.Seek(0, SeekOrigin.Begin);
fileStream.SetLength(0);
await JsonSerializer.SerializeAsync(fileStream, payloads, new JsonSerializerOptions { WriteIndented = true });
}

Comment on lines +28 to +32
// Initialize table after Spring dependency injection
@PostConstruct
public void init() {
try (java.sql.Connection conn = dataSource.getConnection();
java.sql.Statement stmt = conn.createStatement()) {
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: Consider using a proper database migration framework like Flyway or Liquibase for schema management instead of inline SQL execution.

Suggested change
// Initialize table after Spring dependency injection
@PostConstruct
public void init() {
try (java.sql.Connection conn = dataSource.getConnection();
java.sql.Statement stmt = conn.createStatement()) {
// TODO: Replace inline SQL with proper database migration framework (Flyway/Liquibase)
// This method should be removed once proper schema management is implemented
@PostConstruct
public void init() {
try (java.sql.Connection conn = dataSource.getConnection();
java.sql.Statement stmt = conn.createStatement()) {
// Using inline SQL - consider migrating to Flyway or Liquibase

Comment on lines +74 to +75
} 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.

🧹 Maintainability - Poor Error Handling: Implement proper logging with structured error messages and use specific exception types. Consider using a logging framework like SLF4J with appropriate log levels.

Suggested change
} catch (Exception e) {
e.printStackTrace();
} catch (SQLException e) {
logger.error("Database error while storing order for user {}: {}", username, e.getMessage(), e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Order storage failed");
} catch (Exception e) {
logger.error("Unexpected error while processing order for user {}: {}", username, e.getMessage(), e);

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.

1 participant