forge
Explore
Log in

Don't you dare go Hollow

Publish the holiday PATCH bound, raise the profile section cap

Browse files at this commit

d9d0403d45ef432f008a1d10e94144dacd585a09Ahmet Kaan GümüşParent: df8847e
  • feat
    • publish the holiday PATCH bound, raise the profile section cap
Show full message
✨ feat(limits): publish the holiday PATCH bound, raise the profile section cap

`UpdateHoliday.name` now carries the same published `max_length` its create
twin does, so a client validates a PATCH against the same bound the server
re-checks — the runtime refusal was already there, only the contract was
silent.

`MAX_PROFILE_COURSES` goes 20 -> 100: the profile course block became one row
per section, and a teacher's sections are their courses multiplied by the
classes they teach, so the course-era figure truncated a real timetable. It
stays a cap on the response, not on membership — `/courses/me` and
`/classes/me` carry the full lists, and the bound is published so a client can
page for the rest.
README.mdmodified+1 -1
@@ -733,7 +733,7 @@ drift from it**, which is enforced rather than asked for:
733 and fails unless each one is either referenced by `src/web/limits.rs` or733 and fails unless each one is either referenced by `src/web/limits.rs` or
734 listed as a deliberate exclusion *with a reason*. A new constant breaks the734 listed as a deliberate exclusion *with a reason*. A new constant breaks the
735 suite until someone decides, consciously, whether clients need it.735 suite until someone decides, consciously, whether clients need it.
736-- `tests/spec_bounds.rs` builds the OpenAPI document, reads all 241 published736+- `tests/spec_bounds.rs` builds the OpenAPI document, reads all 242 published
737 bounds back out of the emitted JSON, and asserts each equals its constant.737 bounds back out of the emitted JSON, and asserts each equals its constant.
738 This exists because utoipa's `#[schema(max_length = …)]` accepts a **literal738 This exists because utoipa's `#[schema(max_length = …)]` accepts a **literal
739 only** — a `const` there does not compile — so the annotations are739 only** — a `const` there does not compile — so the annotations are
src/constant.rsmodified+7 -3
@@ -41,10 +41,14 @@ pub const MAX_DISPLAY_NAME_LEN: usize = 50;
41 pub const MAX_BIO_LEN: usize = 500;41 pub const MAX_BIO_LEN: usize = 500;
42 pub const MAX_ADDRESS_LEN: usize = 500;42 pub const MAX_ADDRESS_LEN: usize = 500;
43 43
44-/// How many course and class references one profile read embeds. A cap on the44+/// How many **section** rows one profile read embeds — the block is one row
45+/// per section, so this counts sections, not catalogue courses. A cap on the
45 /// response, not on membership — the full lists stay at `/courses/me` and46 /// response, not on membership — the full lists stay at `/courses/me` and
46-/// `/classes/me`.47+/// `/classes/me`. 100 because a teacher's sections are their courses
47-pub const MAX_PROFILE_COURSES: usize = 20;48+/// multiplied by the classes they teach, so the course-era figure truncated a
49+/// real timetable, while one course row's own cap (`MAX_COURSE_SECTIONS`)
50+/// bounds only a single row.
51+pub const MAX_PROFILE_COURSES: usize = 100;
48 pub const MAX_PROFILE_CLASSES: usize = 5;52 pub const MAX_PROFILE_CLASSES: usize = 5;
49 53
50 /// RFC 5321's practical upper bound for a full address.54 /// RFC 5321's practical upper bound for a full address.
src/web/holidays.rsmodified+3 -4
@@ -54,10 +54,9 @@ struct CreateHoliday {
54 54
55 #[derive(Deserialize, ToSchema)]55 #[derive(Deserialize, ToSchema)]
56 struct UpdateHoliday {56 struct UpdateHoliday {
57- /// New name, held to the same bound as `POST` — the `HolidayName` newtype57+ /// New name, held to the same published bound as `POST` — and still
58- /// re-checks it. No `maxLength` here: a published bound needs its own row58+ /// re-checked by the `HolidayName` newtype at runtime.
59- /// in the OpenAPI bounds table, and `CreateHoliday.name` already carries59+ #[schema(max_length = 100)]
60- /// this one.
61 name: Option<String>,60 name: Option<String>,
62 #[schema(example = 1_793_318_400_000_i64)]61 #[schema(example = 1_793_318_400_000_i64)]
63 starts_at: Option<i64>,62 starts_at: Option<i64>,
tests/spec_bounds.rsmodified+6 -0
@@ -1201,6 +1201,12 @@ fn expectations() -> Vec<(&'static str, &'static str, &'static str, i64)> {
1201 "maxLength",1201 "maxLength",
1202 MAX_HOLIDAY_NAME_LEN as i64,1202 MAX_HOLIDAY_NAME_LEN as i64,
1203 ),1203 ),
1204+ (
1205+ "UpdateHoliday",
1206+ "name",
1207+ "maxLength",
1208+ MAX_HOLIDAY_NAME_LEN as i64,
1209+ ),
1204 ("CreateSlot", "topic", "maxLength", MAX_SESSION_TOPIC_LEN as i64),1210 ("CreateSlot", "topic", "maxLength", MAX_SESSION_TOPIC_LEN as i64),
1205 // The offering spine (course × grade_level templates) and the1211 // The offering spine (course × grade_level templates) and the
1206 // per-class instance overrides: same bounds as the catalog course1212 // per-class instance overrides: same bounds as the catalog course