Skip to content

Fix sound type mapping to prevent null insertions#66

Merged
strongmhk merged 1 commit intodevelopfrom
codex/fix-sound_type-default-value-error
Aug 22, 2025
Merged

Fix sound type mapping to prevent null insertions#66
strongmhk merged 1 commit intodevelopfrom
codex/fix-sound_type-default-value-error

Conversation

@strongmhk
Copy link
Copy Markdown
Member

@strongmhk strongmhk commented Aug 22, 2025

Summary

  • default to NONE when alarm sound description is missing or null
  • ensure AlarmEntity defaults sound type to NONE to avoid database insert errors
  • add parameterized tests for SoundType.from mapping scenarios

Testing

  • JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 bash gradlew test (fails: 24 tests completed, 11 failed)

https://chatgpt.com/codex/tasks/task_e_68a8065222c88326911a39bc4ab6ec89

Summary by CodeRabbit

  • 버그 수정

    • 알람 소리 설명이 비어있거나 인식되지 않는 경우 자동으로 ‘소리 없음’으로 처리해 예외와 오동작을 예방했습니다.
    • 알람 생성/편집 시 소리 선택이 누락되어도 기본값으로 ‘소리 없음’이 적용되어 안정성이 향상되었습니다.
  • 테스트

    • 소리 설명과 사운드 유형 매핑, 잘못된 값 및 null 입력에 대한 동작을 검증하는 단위 테스트를 추가했습니다.

- AlarmEntity에 soundType 기본값을 NONE으로 지정하여 sound_type 컬럼 누락을 방지\n\n해결: #0
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Aug 22, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

SoundType.from(String) now returns SoundType.NONE for null or unknown descriptions. AlarmEntity.soundType is default-initialized to SoundType.NONE with @Builder.Default. New tests verify SoundType mapping for valid, invalid, and null inputs.

Changes

Cohort / File(s) Summary
Enum mapping adjustment
src/main/java/akuma/whiplash/domains/alarm/domain/constant/SoundType.java
from(String)에 null 가드 추가. 미매칭/알 수 없는 설명과 null 입력 시 NONE 반환하도록 orElse(NONE)로 변경.
Entity 기본값 및 빌더 지원
src/main/java/akuma/whiplash/domains/alarm/persistence/entity/AlarmEntity.java
soundType 필드에 SoundType.NONE 기본값과 @Builder.Default 추가. 빌더 사용 시 명시 누락해도 null 방지.
단위 테스트 추가
src/test/java/akuma/whiplash/domains/alarm/domain/constant/SoundTypeTest.java
유효/무효/NULL 설명에 대한 SoundType.from 매핑 검증 파라미터라이즈드 테스트 및 케이스 추가.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

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.

🔧 Semgrep (1.128.1)
src/main/java/akuma/whiplash/domains/alarm/domain/constant/SoundType.java

{"version":"1.128.1","results":[],"errors":[{"code":4,"level":"error","type":"InvalidRuleSchemaError","long_msg":"{'pattern-not-either': [{'pattern': '@GetMapping(...)\n...\n@CustomErrorCodes(...)\n...\npublic $RET $M(...){ ... }\n'}, {'pattern': '@PostMapping(...)\n...\n@CustomErrorCodes(...)\n...\npublic $RET $M(...){ ... }\n'}, {'pattern': '@PutMapping(...)\n...\n@CustomErrorCodes(...)\n...\npublic $RET $M(...){ ... }\n'}, {'pattern': '@DeleteMapping(...)\n...\n@CustomErrorCodes(...)\n...\npublic $RET $M(...){ ... }\n'}, {'pattern': '@PatchMapping(...)\n...\n@CustomErrorCodes(...)\n...\npublic $RET $M(...){ ... }\n'}]} is not valid under any of the given schemas","short_msg":"Invalid rule schema","spans":[{"file":".semgrep/semgrep.yml","start":{"line":89,"col":9,"offset":-1},"end":{"line":120,"col":5,"offset":-1},"source_hash":"b582dea1be576d791d43c1fb4f7261c55ab9e08f176bcb3c071834a52d4d2d6d"}]},{"code":7,"level":"error","type":"SemgrepError","message":"invalid configuration file found (1 configs were invalid)"}],"paths":{"scanned":[]},"skipped_rules":[]}

src/test/java/akuma/whiplash/domains/alarm/domain/constant/SoundTypeTest.java

{"version":"1.128.1","results":[],"errors":[{"code":4,"level":"error","type":"InvalidRuleSchemaError","long_msg":"{'pattern-not-either': [{'pattern': '@GetMapping(...)\n...\n@CustomErrorCodes(...)\n...\npublic $RET $M(...){ ... }\n'}, {'pattern': '@PostMapping(...)\n...\n@CustomErrorCodes(...)\n...\npublic $RET $M(...){ ... }\n'}, {'pattern': '@PutMapping(...)\n...\n@CustomErrorCodes(...)\n...\npublic $RET $M(...){ ... }\n'}, {'pattern': '@DeleteMapping(...)\n...\n@CustomErrorCodes(...)\n...\npublic $RET $M(...){ ... }\n'}, {'pattern': '@PatchMapping(...)\n...\n@CustomErrorCodes(...)\n...\npublic $RET $M(...){ ... }\n'}]} is not valid under any of the given schemas","short_msg":"Invalid rule schema","spans":[{"file":".semgrep/semgrep.yml","start":{"line":89,"col":9,"offset":-1},"end":{"line":120,"col":5,"offset":-1},"source_hash":"b582dea1be576d791d43c1fb4f7261c55ab9e08f176bcb3c071834a52d4d2d6d"}]},{"code":7,"level":"error","type":"SemgrepError","message":"invalid configuration file found (1 configs were invalid)"}],"paths":{"scanned":[]},"skipped_rules":[]}

src/main/java/akuma/whiplash/domains/alarm/persistence/entity/AlarmEntity.java

{"version":"1.128.1","results":[],"errors":[{"code":4,"level":"error","type":"InvalidRuleSchemaError","long_msg":"{'pattern-not-either': [{'pattern': '@GetMapping(...)\n...\n@CustomErrorCodes(...)\n...\npublic $RET $M(...){ ... }\n'}, {'pattern': '@PostMapping(...)\n...\n@CustomErrorCodes(...)\n...\npublic $RET $M(...){ ... }\n'}, {'pattern': '@PutMapping(...)\n...\n@CustomErrorCodes(...)\n...\npublic $RET $M(...){ ... }\n'}, {'pattern': '@DeleteMapping(...)\n...\n@CustomErrorCodes(...)\n...\npublic $RET $M(...){ ... }\n'}, {'pattern': '@PatchMapping(...)\n...\n@CustomErrorCodes(...)\n...\npublic $RET $M(...){ ... }\n'}]} is not valid under any of the given schemas","short_msg":"Invalid rule schema","spans":[{"file":".semgrep/semgrep.yml","start":{"line":89,"col":9,"offset":-1},"end":{"line":120,"col":5,"offset":-1},"source_hash":"b582dea1be576d791d43c1fb4f7261c55ab9e08f176bcb3c071834a52d4d2d6d"}]},{"code":7,"level":"error","type":"SemgrepError","message":"invalid configuration file found (1 configs were invalid)"}],"paths":{"scanned":[]},"skipped_rules":[]}


📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2b534bb and cb0fe98.

📒 Files selected for processing (3)
  • src/main/java/akuma/whiplash/domains/alarm/domain/constant/SoundType.java (1 hunks)
  • src/main/java/akuma/whiplash/domains/alarm/persistence/entity/AlarmEntity.java (2 hunks)
  • src/test/java/akuma/whiplash/domains/alarm/domain/constant/SoundTypeTest.java (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/fix-sound_type-default-value-error

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@strongmhk strongmhk merged commit c573838 into develop Aug 22, 2025
1 of 2 checks passed
@strongmhk strongmhk deleted the codex/fix-sound_type-default-value-error branch August 22, 2025 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant