Ignore WS heartbeats and reject empty chat messages (#32)
Deploy Beta / unit-tests (push) Successful in 10s
Unit Tests / test (push) Successful in 9s
Deploy Beta / docker (push) Successful in 25s
Deploy Beta / deploy-beta (push) Successful in 56s

## Summary
- Closes #31
- Ignore WebSocket `type: ping` heartbeats so keepalives no longer create conversations or hit title/LLM pipelines
- Reject empty/whitespace user messages in both chat consumers, `PromptSerializer`, and REST conversation prompt POST

## Test plan
- [x] `UserPromptGuardTestCase`, `PromptSerializerTestCase` blank/whitespace cases
- [x] `WebSocketReceiveGuardTestCase` ping ignore + empty message rejection (both WS routes)
- [ ] Deploy to beta; leave idle tab open and confirm no new rogue conversations
- [ ] Confirm normal chat send still works

Related FE: https://git.aimloperations.com/ai_ml_operations/chat_web_app/issues/51Reviewed-on: #32
This commit was merged in pull request #32.
This commit is contained in:
2026-07-28 05:12:13 -07:00
parent 5d5b448868
commit ee3d47c8c3
8 changed files with 170 additions and 4 deletions
+5
View File
@@ -122,6 +122,11 @@ class PromptSerializer(serializers.ModelSerializer):
"id",
)
def validate_message(self, value: str) -> str:
if value is None or not str(value).strip():
raise serializers.ValidationError("Message text cannot be empty.")
return str(value).strip()
class BasicUserSerializer(serializers.ModelSerializer):
class Meta: