Skip to content

[CSM Portal][BE] Use Key/Keys suffix for enum fields in request schemas - #914

Merged
Rashmika998 merged 2 commits into
wso2-open-operations:v2from
cloby99:feat/csm-backend
Jun 23, 2026
Merged

Rashmika998 merged 2 commits into
wso2-open-operations:v2from
cloby99:feat/csm-backend

Conversation

@cloby99

@cloby99 cloby99 commented Jun 22, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Rename enum request fields to use Key/Keys suffix to align with entity-service conventions:
    • CaseCreatePayload: priority → priorityKey, issueType → issueTypeKey
    • UpdateCaseRequest: state → stateKey, priority → priorityKey, workState → workStateKey
    • CaseCommentCreatePayload: commentType → typeKey, body → content
  • Fix PatchCase handler to read stateKey/workStateKey from request body for state transition validation
  • Fix CreateCaseComment handler to read typeKey for work-note exemption check
  • Update CaseComment response schema to match entity-service shape (type, content, createdOn)
  • Update all tests to use the new field names

Summary by CodeRabbit

Release Notes

Chores

  • Updated API field naming conventions for enhanced consistency. Case creation and updates now use stateKey, priorityKey, workStateKey, and issueTypeKey. Comment operations use typeKey for type and content for the message body. These changes standardize request and response contracts across case management endpoints. Review the updated API documentation.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 877d7459-eed8-49d7-bd52-f2b892226f5d

📥 Commits

Reviewing files that changed from the base of the PR and between bf95eb7 and db98a5e.

📒 Files selected for processing (3)
  • apps/csm-portal/backend/internal/handler/cases.go
  • apps/csm-portal/backend/internal/handler/cases_test.go
  • apps/csm-portal/backend/openapi.yaml

📝 Walkthrough

Walkthrough

Renames JSON payload field keys across the OpenAPI spec, Go handler struct tags, and test fixtures: state→stateKey, priority→priorityKey, workState→workStateKey, type→typeKey, body→content, issueType→issueTypeKey. No behavioral logic changes; only the expected request/response field names are updated.

Changes

JSON Field Key Renaming

Layer / File(s) Summary
OpenAPI schema field renames
apps/csm-portal/backend/openapi.yaml
UpdateCaseRequest oneOf/required keys change from state/priority/workState to stateKey/priorityKey/workStateKey; CaseCreatePayload required fields become priorityKey/issueTypeKey; CaseCommentCreatePayload renames type/body to typeKey/content; CaseComment renames body to content.
Handler struct tag and comment updates
apps/csm-portal/backend/internal/handler/cases.go
CreateCaseComment reads typeKey instead of type to drive work_note bypass logic; PatchCase struct JSON tags changed to stateKey/workStateKey; inline comment updated accordingly.
Test payload and mock fixture updates
apps/csm-portal/backend/internal/handler/cases_test.go
All test request bodies updated to use priorityKey, issueTypeKey, typeKey, stateKey, workStateKey; TestSearchCaseComments mock response renames commentType→type, body→content, createdAt→createdOn.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • wso2-open-operations/cs-tools#913: Updates the same cases/comment request contract JSON fields to *Key variants including typeKey, stateKey, workStateKey, priorityKey, and issueTypeKey at the handler mapping level.
  • wso2-open-operations/cs-tools#892: Modifies CreateCaseComment in the same handler file to parse the comment type field early for the work_note state-guard bypass logic.
  • wso2-open-operations/cs-tools#897: Modifies the OpenAPI contract for PATCH /cases/{id} to add work-state update support, overlapping with the workStateKey rename in this PR.

Suggested labels

Type/Improvement, Area/Backend, App/CSM Portal

Suggested reviewers

  • v15a1
  • suhand
  • kasunsiyambalapitiya

Poem

🐇 Hop, hop, rename in a flash,
type became typeKey in a dash!
state grew a suffix, body turned content,
The contract now speaks with a Key intent.
No logic was harmed in the making of this —
just fields wearing new names, pure renaming bliss! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description covers purpose, goals, approach, and testing but lacks several required template sections like user stories, release notes, documentation, and security checks. Consider adding missing sections from the template such as user stories, release notes, documentation impact, security checks, and test environment details for completeness.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: renaming enum fields to use Key/Keys suffix across request schemas in the CSM Portal backend.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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.

@cloby99

cloby99 commented Jun 22, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Rashmika998
Rashmika998 merged commit 913b752 into wso2-open-operations:v2 Jun 23, 2026
1 check passed
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