Skip to content

fix: letter text is too long (thai)#2183

Merged
jo-elimu merged 2 commits intomainfrom
1996-text-is-too-long-error-for-thai-diacritic
May 7, 2025
Merged

fix: letter text is too long (thai)#2183
jo-elimu merged 2 commits intomainfrom
1996-text-is-too-long-error-for-thai-diacritic

Conversation

@jo-elimu
Copy link
Copy Markdown
Member

@jo-elimu jo-elimu commented May 7, 2025

closes #2011

Issue Number

Purpose

Technical Details

Testing Instructions

Screenshots


Format Checks

Note

Files in PRs are automatically checked for format violations with mvn spotless:check.

If this PR contains files with format violations, run mvn spotless:apply to fix them.

@jo-elimu jo-elimu self-assigned this May 7, 2025
@jo-elimu jo-elimu requested a review from a team as a code owner May 7, 2025 06:56
@jo-elimu jo-elimu requested review from AshishBagdane, SnehaHS65 and Souvik-Cyclic and removed request for a team May 7, 2025 06:56
@jo-elimu jo-elimu linked an issue May 7, 2025 that may be closed by this pull request
@codecov
Copy link
Copy Markdown

codecov bot commented May 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 15.18%. Comparing base (808726d) to head (71880ef).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #2183   +/-   ##
=========================================
  Coverage     15.18%   15.18%           
  Complexity      391      391           
=========================================
  Files           232      232           
  Lines          6209     6209           
  Branches        717      717           
=========================================
  Hits            943      943           
  Misses         5215     5215           
  Partials         51       51           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented May 7, 2025

Caution

Review failed

The pull request is closed.

"""

Walkthrough

The changes increase the maximum allowed length of the text field in the Letter entity from 2 to 3 characters. This is reflected in the Java entity, the JPA schema export, and a new database migration script. The letter creation and edit JSP forms were updated to enforce the new maximum input length. The Maven project version is also updated from 2.6.5-SNAPSHOT to 2.6.7-SNAPSHOT.

Changes

Files/Paths Change Summary
src/main/java/ai/elimu/entity/content/Letter.java Increased text field length constraint from 2 to 3 characters in both validation and column size.
src/main/resources/META-INF/jpa-schema-export.sql Changed Letter.text column type from varchar(2) to varchar(3).
src/main/resources/db/migration/2006007.sql Added migration script to alter Letter.text column to VARCHAR(3) NOT NULL.
src/main/webapp/WEB-INF/jsp/content/letter/create.jsp Added maxlength="3" attribute to the text input field.
src/main/webapp/WEB-INF/jsp/content/letter/edit.jsp Added maxlength="3" attribute to the text input field.
pom-dependency-tree.txt Updated main project artifact version from 2.6.5-SNAPSHOT to 2.6.7-SNAPSHOT.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WebApp
    participant Database

    User->>WebApp: Submit new Letter with up to 3-character text
    WebApp->>Database: Insert/Update Letter (text VARCHAR(3))
    Database-->>WebApp: Success/Failure response
    WebApp-->>User: Confirmation or error message
Loading

Assessment against linked issues

Objective Addressed Explanation
Increase @Size and @Column limits for text field to 3 characters (#2011)
Fix "Text is too long" error for Thai diacritic input (#1996)

Suggested reviewers

  • vrudas
  • shiv810

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0f9fe0e and 71880ef.

📒 Files selected for processing (2)
  • src/main/webapp/WEB-INF/jsp/content/letter/create.jsp (1 hunks)
  • src/main/webapp/WEB-INF/jsp/content/letter/edit.jsp (1 hunks)

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b25cc7c and 0f9fe0e.

📒 Files selected for processing (4)
  • pom-dependency-tree.txt (1 hunks)
  • src/main/java/ai/elimu/entity/content/Letter.java (1 hunks)
  • src/main/resources/META-INF/jpa-schema-export.sql (1 hunks)
  • src/main/resources/db/migration/2006007.sql (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
pom-dependency-tree.txt (1)
Learnt from: jo-elimu
PR: elimu-ai/webapp#0
File: :0-0
Timestamp: 2025-05-03T08:01:30.217Z
Learning: The elimu-ai/webapp repository has a dependency on ai.elimu:model (version 2.0.97) that provides shared model classes and enums. The Language enum should be imported from ai.elimu.model.v2.enums.Language instead of creating local duplicates.
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: test_ui
  • GitHub Check: test_ui
  • GitHub Check: test_ui
  • GitHub Check: build (windows-latest, 21)
  • GitHub Check: build (windows-latest, 17)
  • GitHub Check: test_rest
  • GitHub Check: build (ubuntu-latest, 21)
  • GitHub Check: build (macos-latest, 21)
  • GitHub Check: build (ubuntu-latest, 17)
  • GitHub Check: build (macos-latest, 17)
  • GitHub Check: test_rest
  • GitHub Check: test_rest
🔇 Additional comments (2)
pom-dependency-tree.txt (1)

1-1: Approve version bump
The project version has been updated from 2.6.5-SNAPSHOT to 2.6.7-SNAPSHOT, aligning with the entity and schema changes.

src/main/resources/db/migration/2006007.sql (1)

1-3:

Details

❓ Verification inconclusive

Migration script updates text column length
The migration correctly alters Letter.text to VARCHAR(3) NOT NULL. Ensure there are no existing NULL values in the text column before applying the migration.

You can run a check like:


🏁 Script executed:

#!/bin/bash
# Verify no NULL text values exist prior to migration
mysql -Nse "SELECT COUNT(*) FROM Letter WHERE text IS NULL;"

Length of output: 158


Manual Verification Required: Confirm no NULL values in Letter.text

File: src/main/resources/db/migration/2006007.sql
Lines: 1-3

# 2.6.7

ALTER TABLE `Letter` MODIFY `text` VARCHAR(3) NOT NULL;

We attempted to run the automated check, but the mysql CLI is unavailable in this environment. Please manually verify that there are no existing NULL values in the Letter.text column before applying this migration:

  • Execute in your MySQL client:
    SELECT COUNT(*) FROM Letter WHERE text IS NULL;
  • Confirm the result is 0.
  • If any rows are returned, update or remove them prior to running the migration.

usageCount integer,
diacritic bit not null,
text varchar(2),
text varchar(3),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Mismatch in NOT NULL constraint
The text column definition lacks a NOT NULL constraint, causing inconsistency with the migration script and @NotNull in the entity. Please update to:

-        text varchar(3),
+        text varchar(3) NOT NULL,

Comment on lines +16 to +17
@Size(max = 3)
@Column(length = 3)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Include nullable=false in @column
To enforce the @NotNull constraint at the DDL level, add nullable=false to the @Column annotation:

-  @Column(length = 3)
+  @Column(length = 3, nullable = false)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@Size(max = 3)
@Column(length = 3)
@Size(max = 3)
@Column(length = 3, nullable = false)

@jo-elimu jo-elimu merged commit c71a9df into main May 7, 2025
13 checks passed
@jo-elimu jo-elimu deleted the 1996-text-is-too-long-error-for-thai-diacritic branch May 7, 2025 07:06
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.

"Text is too long" error for Thai diacritic

1 participant