Skip to content

fix(fonts): address PR #190 code review findings#193

Merged
sharkAndshark merged 1 commit intofeat/font-service-resources-uifrom
fix/font-service-review-pr190
Mar 30, 2026
Merged

fix(fonts): address PR #190 code review findings#193
sharkAndshark merged 1 commit intofeat/font-service-resources-uifrom
fix/font-service-review-pr190

Conversation

@sharkAndshark
Copy link
Copy Markdown
Owner

Summary

Addresses code review findings from PR #190.

Fixes

  1. Timestamp consistency — Use CURRENT_TIMESTAMP for created_at and published_at in SQL instead of Rust-side Utc::now().to_rfc3339(), matching the rest of the codebase and eliminating DuckDB implicit RFC3339 to TIMESTAMP parsing fragility.

  2. Deduplicated test-mode workspace bootstrap — Extract workspace::ensure_test_mode_workspace() shared function, eliminating ~100 lines of identical bootstrap code duplicated between font_handlers.rs and upload.rs.

  3. Deduplicated FontItem row mapping — Extract read_font_row() helper for the 13-column row mapping previously duplicated in list_fonts and get_font.

  4. Error loggingupdate_font_error now logs DB errors via warn! instead of silently discarding them with let _ =.

  5. Font file extension — Save uploaded fonts with their original extension (e.g., original.ttf instead of original) for easier filesystem inspection.

Note on race condition (Item 1 from review)

The review flagged a TOCTOU race in publish_font between the SELECT EXISTS check and the UPDATE. This race is already prevented by the application-level Mutex<Connection> - the lock is held continuously from the conflict check through the update. No additional fix needed.

Test results

  • 84 unit tests pass
  • 150 API integration tests pass
  • 7 font API tests pass
  • 6 PostGIS tests pass
  • 33 frontend unit tests pass
  • 50 E2E tests pass

…red helpers, improve robustness

- Use CURRENT_TIMESTAMP for font created_at and published_at instead of
  Rust-side Utc::now(), consistent with the rest of the codebase
- Extract test-mode workspace bootstrap from font_handlers.rs and
  upload.rs into workspace::ensure_test_mode_workspace(), eliminating
  ~100 lines of duplicated code
- Extract read_font_row() helper to deduplicate the 13-column FontItem
  row mapping used in list_fonts and get_font
- Log DB errors in update_font_error instead of silently discarding them
- Save uploaded font with original file extension (e.g. original.ttf)
  for easier filesystem inspection
@sharkAndshark sharkAndshark merged commit 3045ba7 into feat/font-service-resources-ui Mar 30, 2026
7 checks 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.

1 participant