Conversation
…TF-8 fix, README update Agent-Logs-Url: https://github.com/markmnl/fmsg-webapi/sessions/8c2bb90d-2c10-4faa-8752-688a147715d8 Co-authored-by: markmnl <2630321+markmnl@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes JWT jti-based replay prevention and introduces an optional short_text preview field for text message bodies, along with additional request validation and documentation updates.
Changes:
- Removed in-process JWT replay detection (
jticache) and updated tests/docs to reflect token reuse being allowed. - Added
short_textsupport for messages (configurable preview size; included in list and single-message responses when applicable). - Strengthened handler validations (address shape checks,
pid/topic/add_torelationship rules) and refactored path traversal protection.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/models/models.go | Adds ShortText field to the message model JSON shape. |
| src/middleware/jwt.go | Removes jti replay tracking; exports IsValidAddr. |
| src/middleware/jwt_test.go | Updates tests to use IsValidAddr and to allow token reuse. |
| src/middleware/jti_cache.go | Deletes the in-process jti replay cache implementation. |
| src/main.go | Wires new FMSG_API_SHORT_TEXT_SIZE into MessageHandler. |
| src/handlers/messages.go | Implements short_text extraction, adds validation helpers, updates queries to load filepath, and refactors path checks. |
| src/handlers/messages_test.go | Adds unit tests for MIME detection, safe path handling, and short-text extraction behavior. |
| src/handlers/attachments.go | Updates route comments to /fmsg paths. |
| README.md | Documents short_text behavior/config and makes jti optional in JWT docs. |
Comments suppressed due to low confidence (1)
src/middleware/jwt_test.go:37
- In this test the failure message still refers to
isValidAddr(...), but the function under test is nowIsValidAddr. Updating the format string will make failures easier to interpret.
if got := IsValidAddr(tt.addr); got != tt.want {
t.Errorf("isValidAddr(%q) = %v, want %v", tt.addr, got, tt.want)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.