Skip to content

fix: Publishing Push Job Management API - 10 issues resolved#34874

Open
hassandotcms wants to merge 5 commits intomainfrom
claude/issue-34862-20260304-1534
Open

fix: Publishing Push Job Management API - 10 issues resolved#34874
hassandotcms wants to merge 5 commits intomainfrom
claude/issue-34862-20260304-1534

Conversation

@hassandotcms
Copy link
Contributor

This PR addresses all 10 issues identified in the Publishing Push publishing job management REST endpoints:

HIGH Priority Fixes:

  1. DELETE /{bundleId} now returns 404 for non-existent bundles
  2. POST /push/{bundleId} validates date format before bundle lookup
  3. Added machine-readable enums for status query parameters

MEDIUM Priority Fixes:
4. Added allowableValues for deliveryStrategy parameter
5. Documented operation case-insensitivity vs deliveryStrategy case-sensitivity
6. Added date-time format and timezone requirements for date fields
7. Exposed filterKey in response views for API reproducibility

LOW Priority Fixes:
8. Documented purge async behavior and WebSocket notifications for API clients
9. Fixed bundleId examples to use correct ULID format
10. Added port range validation pattern for EndpointDetailView.port

Additional Security & Validation Improvements:

  • Added bundleId format validation to prevent XSS attacks
  • Fixed pagination validation to return 400 instead of silent clamping
  • Enhanced OpenAPI documentation with proper schema constraints

Resolves #34862

Generated with Claude Code

This commit addresses all 10 issues identified in the Publishing Push publishing job management REST endpoints:

**HIGH Priority Fixes:**
1. DELETE /{bundleId} now returns 404 for non-existent bundles
2. POST /push/{bundleId} validates date format before bundle lookup
3. Added machine-readable enums for status query parameters

**MEDIUM Priority Fixes:**
4. Added allowableValues for deliveryStrategy parameter
5. Documented operation case-insensitivity vs deliveryStrategy case-sensitivity
6. Added date-time format and timezone requirements for date fields
7. Exposed filterKey in response views for API reproducibility

**LOW Priority Fixes:**
8. Documented purge async behavior and WebSocket notifications for API clients
9. Fixed bundleId examples to use correct ULID format
10. Added port range validation pattern for EndpointDetailView.port

**Additional Security & Validation Improvements:**
- Added bundleId format validation to prevent XSS attacks
- Fixed pagination validation to return 400 instead of silent clamping
- Enhanced OpenAPI documentation with proper schema constraints

Resolves #34862

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Freddy Montes <fmontes@users.noreply.github.com>
hassandotcms and others added 4 commits March 5, 2026 21:49
- Restore dual-check (bundle + audit table) for DELETE endpoint to
  prevent orphaned audit records from becoming undeletable
- Add DeliveryStrategyDeserializer to return clean error messages
  for invalid deliveryStrategy values without exposing Java class names
- Cache parsed dates in push endpoint to avoid redundant double parsing
- Update 3 pagination tests to expect 400 errors instead of clamping

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@hassandotcms hassandotcms marked this pull request as ready for review March 10, 2026 13:05
}

// Validate bundleId format (prevent XSS and invalid characters)
if (!bundleId.matches("^[a-zA-Z0-9\\-_]+$")) {
Copy link
Contributor

@dario-daza dario-daza Mar 12, 2026

Choose a reason for hiding this comment

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

I reckon we can reuse this code over here in a separate method.

// Validate bundleId format (prevent XSS and invalid characters)
        if (!bundleId.matches("^[a-zA-Z0-9\\-_]+$")) {
            throw new BadRequestException("Invalid bundle ID format. Only alphanumeric characters, hyphens, and underscores are allowed.");
        }

Copy link
Contributor

@ihoffmann-dot ihoffmann-dot Mar 12, 2026

Choose a reason for hiding this comment

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

I agree, also we are repeating that regex in many places

// 8. Execute operation based on type — parse only the dates required per operation
final String operation = form.getOperation().toLowerCase();
// 9. Execute operation based on type (dates already parsed in step 4)
switch (operation) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The switch does not have a default case. Adding one improves usability


// Validate bundleId format (prevent XSS and invalid characters)
if (!bundleId.matches("^[a-zA-Z0-9\\-_]+$")) {
throw new BadRequestException("Invalid bundle ID format. Only alphanumeric characters, hyphens, and underscores are allowed.");
Copy link
Contributor

Choose a reason for hiding this comment

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

The regex is called via String.matches() in three places, which recompiles the pattern on every invocation:

if (!bundleId.matches("^[a-zA-Z0-9\-_]+$")) { ... }

Should be extracted to a compiled constant:

private static final Pattern BUNDLE_ID_PATTERN = Pattern.compile("^[a-zA-Z0-9_-]+$");
// then: if (!BUNDLE_ID_PATTERN.matcher(bundleId).matches()) { ... }

final int validPerPage = Math.min(Math.max(1, perPage), MAX_PER_PAGE);
final int offset = (validPage - 1) * validPerPage;
// Validate pagination parameters
if (page < 1) {
Copy link
Member

Choose a reason for hiding this comment

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

it says must be 1 or greater but not checking equals 1

if (page < 1) {
throw new BadRequestException("Page must be 1 or greater (got: " + page + ")");
}
if (perPage < 1 || perPage > MAX_PER_PAGE) {
Copy link
Member

Choose a reason for hiding this comment

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

same here

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

Labels

Area : Backend PR changes Java/Maven backend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

bug: Push Publishing Job Management API — 4 issues in error handling and input validation

5 participants