Skip to content

chore: error handling + swagger content-type + SPA alloc #216

Description

@ajianaz

Problem

Tiga minor issue dari cora-scan yang masih outstanding:

1. `count_issues().unwrap_or(0)` sembunyikan DB error (`server.rs:405`)

Database failure di-mask sebagai "0 total" — operator tidak tahu DB-nya bermasalah. Harus log warning + propagate status code yang benar.

2. OpenAPI YAML disajikan sebagai HTML (`swagger.rs:42`)

`Content-Type: text/html` padahal body YAML. Tooling yang scrape Swagger (`openapi-generator`, `redocly`, dll) tidak bisa parse. Harus `application/yaml`.

3. SPA fallback meng-copy HTML ke String baru tiap request (`spa.rs:42`)

`rust-embed` sudah cache asset di binary, tapi handler melakukan alloc per request. Pakai `OnceLock` atau serve sebagai `&[u8]` langsung.

Solution

  1. `server.rs:405`: log warning + return 500 (atau 0 dengan `tracing::warn!`).
  2. `swagger.rs:42`: set `Content-Type: application/yaml` untuk raw YAML endpoint.
  3. `spa.rs:42`: cache HTML statis di `OnceLock`.

Acceptance

  • DB error saat count tidak silent
  • OpenAPI YAML endpoint punya content-type `application/yaml`
  • SPA index tidak alloc per request
  • `cargo clippy` + `cargo test` clean

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions