Skip to content

Fix edit ticket: form submit, s3key column mapping, and audit log con…#140

Open
viktorlindell12 wants to merge 2 commits into
mainfrom
fix/edit-ticket-form
Open

Fix edit ticket: form submit, s3key column mapping, and audit log con…#140
viktorlindell12 wants to merge 2 commits into
mainfrom
fix/edit-ticket-form

Conversation

@viktorlindell12

@viktorlindell12 viktorlindell12 commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes

    • Improved ticket editing form submission handling
    • Refined file upload system validation
  • Chores

    • Updated database constraints for data consistency

@coderabbitai

coderabbitai Bot commented Apr 27, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@viktorlindell12 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 33 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: db6520e5-42e9-4239-ba81-0df2647b48fe

📥 Commits

Reviewing files that changed from the base of the PR and between 5808252 and 54c263d.

📒 Files selected for processing (1)
  • src/main/resources/static/js/script.js
📝 Walkthrough

Walkthrough

This PR contains three distinct changes: a JPA column mapping adjustment for the s3Key field in UploadedFile, a database migration updating the audit log action constraint with new action types, and template updates embedding CSRF security tokens in meta tags while adding an id attribute to the submit button.

Changes

Cohort / File(s) Summary
JPA Entity Mapping
src/main/java/org/example/untitled/usercase/UploadedFile.java
Adjusted @Column annotation on the s3Key field to explicitly map to database column "s3key" while maintaining nullable status.
Database Migration
src/main/resources/db/migration/V10__update_audit_log_action_constraint.sql
Updated audit_log_action_check constraint to enforce strict action values including CASE_CREATED, CASE_ASSIGNED, CASE_STATUS_CHANGED, COMMENT_ADDED, FILE_UPLOADED, USER_ROLE_CHANGED, and CASE_UPDATED.
Template Security & UI Enhancement
src/main/resources/templates/edit_ticket.html
Embedded CSRF token and header name into <meta> tags for client-side access; added id="submitBtn" attribute to the Save Changes button while preserving existing functionality.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • apaegs

Poem

🐰 A column renamed with care,
Audit actions declared fair,
CSRF tokens hiding in meta so sweet,
Security layers, now quite complete!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the main changes: form submit fix, s3key column mapping, and audit log constraint updates across the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/edit-ticket-form

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/main/resources/db/migration/V10__update_audit_log_action_constraint.sql (1)

4-4: Add trailing newline at end of file.

SQL files should end with a newline character for consistency with standard text file conventions and to avoid issues with certain version control systems and tools.

📝 Proposed fix
-        CHECK (action IN ('CASE_CREATED', 'CASE_ASSIGNED', 'CASE_STATUS_CHANGED', 'COMMENT_ADDED', 'FILE_UPLOADED', 'USER_ROLE_CHANGED', 'CASE_UPDATED'));
+        CHECK (action IN ('CASE_CREATED', 'CASE_ASSIGNED', 'CASE_STATUS_CHANGED', 'COMMENT_ADDED', 'FILE_UPLOADED', 'USER_ROLE_CHANGED', 'CASE_UPDATED'));
+
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/resources/db/migration/V10__update_audit_log_action_constraint.sql`
at line 4, The SQL file ends without a trailing newline on the CHECK constraint
line ("CHECK (action IN ('CASE_CREATED', 'CASE_ASSIGNED', 'CASE_STATUS_CHANGED',
'COMMENT_ADDED', 'FILE_UPLOADED', 'USER_ROLE_CHANGED', 'CASE_UPDATED'));"); open
that migration file and add a single newline character at the end of the file so
the file terminates with a trailing newline, then save and commit the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main/resources/templates/edit_ticket.html`:
- Line 33: The uploadNewFile() handler in script.js currently hardcodes
submitBtn.innerText = "Create Ticket" on multiple completion/error paths which
causes the Edit page button (id="submitBtn") to flip from "Save Changes" to
"Create Ticket"; fix by capturing the button's original text at the start of
uploadNewFile() (e.g., const originalLabel = submitBtn.innerText) and restore
originalLabel instead of the hardcoded string in all places where
submitBtn.innerText is reset (references: uploadNewFile(), submitBtn variable
and the lines that set submitBtn.innerText = "Create Ticket"); ensure the
originalLabel is used on success, error, and finally paths so Create and Edit
pages keep their correct labels.

---

Nitpick comments:
In `@src/main/resources/db/migration/V10__update_audit_log_action_constraint.sql`:
- Line 4: The SQL file ends without a trailing newline on the CHECK constraint
line ("CHECK (action IN ('CASE_CREATED', 'CASE_ASSIGNED', 'CASE_STATUS_CHANGED',
'COMMENT_ADDED', 'FILE_UPLOADED', 'USER_ROLE_CHANGED', 'CASE_UPDATED'));"); open
that migration file and add a single newline character at the end of the file so
the file terminates with a trailing newline, then save and commit the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 08971a11-e233-4799-b2b0-27386ef2186a

📥 Commits

Reviewing files that changed from the base of the PR and between 3943463 and 5808252.

📒 Files selected for processing (3)
  • src/main/java/org/example/untitled/usercase/UploadedFile.java
  • src/main/resources/db/migration/V10__update_audit_log_action_constraint.sql
  • src/main/resources/templates/edit_ticket.html

<footer class="ticket-footer">
<div class="ticket-button">
<button onclick="uploadNewFile()" type="button">Save Changes</button>
<button onclick="uploadNewFile()" type="button" id="submitBtn">Save Changes</button>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm the hardcoded "Create Ticket" reset in uploadNewFile and that submitBtn id is also used by the create page.
rg -nP -C2 '"Create Ticket"|getElementById\(\s*[\x27"]submitBtn'
fd -t f -e html | xargs rg -nP -C1 'id\s*=\s*"submitBtn"|onclick\s*=\s*"uploadNewFile'

Repository: ithsjava25/project-backend-untitled-team

Length of output: 3270


Button text will be reset to "Create Ticket" on the Edit Ticket page.

Now that this button is wired with id="submitBtn", the uploadNewFile() function in script.js will reset its text on all completion/error paths. Specifically, lines 45, 70, 76, and 80 hardcode submitBtn.innerText = "Create Ticket", causing the button to incorrectly switch from "Save Changes" to "Create Ticket" after any upload completes or fails. Parameterize the reset label in uploadNewFile() (e.g., capture and restore the original button text) so the correct label is preserved for both create and edit pages.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/resources/templates/edit_ticket.html` at line 33, The
uploadNewFile() handler in script.js currently hardcodes submitBtn.innerText =
"Create Ticket" on multiple completion/error paths which causes the Edit page
button (id="submitBtn") to flip from "Save Changes" to "Create Ticket"; fix by
capturing the button's original text at the start of uploadNewFile() (e.g.,
const originalLabel = submitBtn.innerText) and restore originalLabel instead of
the hardcoded string in all places where submitBtn.innerText is reset
(references: uploadNewFile(), submitBtn variable and the lines that set
submitBtn.innerText = "Create Ticket"); ensure the originalLabel is used on
success, error, and finally paths so Create and Edit pages keep their correct
labels.

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