Skip to content

refactor: enhance GSTIN validation error messages#3770

Merged
karm1000 merged 1 commit intodevelopfrom
better-gstin-error-msg
Nov 6, 2025
Merged

refactor: enhance GSTIN validation error messages#3770
karm1000 merged 1 commit intodevelopfrom
better-gstin-error-msg

Conversation

@Abdeali099
Copy link
Copy Markdown
Member

@Abdeali099 Abdeali099 commented Nov 5, 2025

Note

Backport to V-15

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced GSTIN validation error handling with structured messaging and visual indicators for clearer feedback during validation failures.

@Abdeali099 Abdeali099 self-assigned this Nov 5, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Nov 5, 2025

Walkthrough

The pull request enhances GSTIN validation error handling by introducing a shared options object with consistent styling properties (title and indicator) and converting simple string error messages to structured object-based frappe.msgprint calls.

Changes

Cohort / File(s) Summary
GSTIN Validation Error Handling
india_compliance/public/js/utils.js
Added local opts constant with title and indicator properties. Replaced string error messages with object-based frappe.msgprint calls for length and invalid GSTIN validation failures. Updated control flow to use else if for invalid GSTIN case.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single file modification with repetitive pattern applied to error handling
  • Straightforward refactoring focused on message structure consistency
  • Minimal logic changes; primarily involves understanding frappe.msgprint API usage

Suggested labels

backport version-15-hotfix

Suggested reviewers

  • karm1000
  • vorasmit

Poem

🐰 With structured errors, so neat and so clear,
Red indicators appear far and near,
Where validation once stumbled with words,
Now messages flow like the most graceful birds,
A small touch of polish, a validator's cheer! ✨

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor: enhance GSTIN validation error messages' clearly and specifically describes the main change: improving GSTIN validation error message handling with better structure and options.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch better-gstin-error-msg

📜 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 c312d10 and 8969581.

📒 Files selected for processing (1)
  • india_compliance/public/js/utils.js (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2025-09-04T13:11:55.495Z
Learnt from: karm1000
Repo: resilient-tech/india-compliance PR: 3636
File: india_compliance/gst_india/utils/e_invoice.py:0-0
Timestamp: 2025-09-04T13:11:55.495Z
Learning: For e-invoice API error codes 3028 and 3029, the response will always contain a GSTIN that can be extracted from the error message using GSTIN_FORMAT regex.

Applied to files:

  • india_compliance/public/js/utils.js
📚 Learning: 2025-06-24T11:21:06.708Z
Learnt from: karm1000
Repo: resilient-tech/india-compliance PR: 3418
File: india_compliance/gst_india/doctype/gstr_1_beta/gstr_1_beta.js:0-0
Timestamp: 2025-06-24T11:21:06.708Z
Learning: For optional/suggested features in the GSTR-1 Beta workflow (like rounding difference journal entries), silent failure handling is preferred over showing alerts or warnings to users, as these features should not interrupt the main workflow when they cannot be executed.

Applied to files:

  • india_compliance/public/js/utils.js
📚 Learning: 2025-04-25T11:12:59.799Z
Learnt from: Ninad1306
Repo: resilient-tech/india-compliance PR: 3344
File: india_compliance/gst_india/report/gst_account_wise_summary/gst_account_wise_summary.py:18-20
Timestamp: 2025-04-25T11:12:59.799Z
Learning: In India Compliance GST reports, date_range is defined as a mandatory filter in the report configuration, making additional defensive coding for its presence unnecessary as the Frappe framework enforces required filters before calling the execute function.

Applied to files:

  • india_compliance/public/js/utils.js
🧬 Code graph analysis (1)
india_compliance/public/js/utils.js (1)
india_compliance/public/js/regex_constants.js (2)
  • GSTIN_REGEX (17-19)
  • GSTIN_REGEX (17-19)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Mergify Merge Protections
  • GitHub Check: Summary
🔇 Additional comments (3)
india_compliance/public/js/utils.js (3)

310-310: Good addition of shared error styling options.

The opts constant effectively centralizes error message styling properties (title and indicator), following DRY principles and ensuring consistent error presentation.


312-321: LGTM! Proper error handling with consistent styling.

The object-based frappe.msgprint call with spread operator correctly applies the shared styling options. The early return ensures subsequent code (line 323) only executes when GSTIN exists and has the correct length.


325-332: LGTM! Consistent error messaging pattern.

The change from else to else if (show_msg) is more explicit and maintains consistency with the length validation error handling above. The structured error message with spread operator correctly applies shared styling options.


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.

@karm1000 karm1000 enabled auto-merge November 6, 2025 12:05
@karm1000 karm1000 disabled auto-merge November 6, 2025 12:05
@karm1000 karm1000 merged commit df2a244 into develop Nov 6, 2025
13 checks passed
@karm1000 karm1000 deleted the better-gstin-error-msg branch November 6, 2025 12:06
ljain112 added a commit that referenced this pull request Nov 6, 2025
…tfix/pr-3770

refactor: enhance GSTIN validation error messages (backport #3770)
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.

3 participants