backend
Technical notes on web development, DevOps, and AI integration.
157 articles
- 09:14backend
Three Layers of Validation for One Query Parameter
An enum filter guarded at the handler, the repository, and the SQL layer. Each layer protects a different class of caller.
TL;DR: Editor logic was embedded in a SQL query. The query was simplified to use a column directly. A three-layer validation system was added for security.
#golang#api#sql - 14:15database
The Enum Value That Only Failed at INSERT Time
App validation and the OpenAPI schema accepted the new enum values; the MySQL column refused them. Error 1265 surfaced only at INSERT.
TL;DR: A MySQL error occurred due to data truncation. The issue arose from a mismatch between the application and database. A migration was needed to append new values to the column.
#mysql#schema#database-migration - 13:02backend
The edit form one bidang should never have opened
Role checks answer who may manage staff, never which row they may touch. A row-ownership guard closes the gap.
TL;DR: Someone edited a staff record from a different bidang. The issue was caused by a lack of object-level authorization. A guard function was added to prevent this.
#security#authorization#owasp - 10:53backend
Guard Before the Payload: Requirements Are Global-Write Only
A cross-module document checklist could be rewritten by any account holding a service write permission. The guard now refuses before reading the payload.
TL;DR: Permission gate was too narrow. Added scope check to write path. Guard now runs before validation.
#go#rbac#api - 03:20backend
A Guard That Refuses Before the Payload Is Read
The organisation module finally has an owner: one guard in the service layer, one fixed 403, and one sidebar group that follows the owner.
TL;DR: Commit 96e93ae adds a guard function to check write permissions. The function runs before validation and returns an error for unauthorized bidang. A test ensures the guard's position and prevents unauthorized repository access.
#go#rbac#authorization - 11:47backend
The Only Admin Module Without a Write Guard
An authorization audit found seven of eight admin modules guarded. The last one closed by reusing the pattern already in the codebase.
TL;DR: The KotaPortal service portal project had an admin module without a scope check. The fix reused a guard pattern from neighboring modules. The handler now passes middleware into the service with a two-function guard.
#go#security#rbac - 00:24backend
The Column Width Belongs in the Validator, Not in MySQL
Length validation must mirror the column width, not leave it to the database. When 31 characters reach the query, MySQL strict mode answers 500.
TL;DR: The KotaPortal admin form accepted 31 characters but threw a 500 error. The tipe_cabor column was declared VARCHAR(30). Validation was added to prevent this error.
#go#validation#api - 23:51frontend
Asked for 100, Got 20: The Counter Said 54
The limit you send is a hope, not a contract. A list endpoint silently clamped limit 100 down to 20, so a counter reading 54 rendered 20 cards.
TL;DR: The KotaPortal portal displays 20 cards despite a reported total of 54. The server limits requests to 50 and silently reduces larger limits to 20. The fix involves fetching one page at a time.
#react#nextjs#typescript - 20:16backend
Four Bars With the Same Name: An Import Key That Must Not Guess
A three-column natural key, a NULL-safe comparison, and a guard that fires before the first query.
TL;DR: Data was moved from an intake file into two tables. A key issue arose with duplicate organization names. The code was fixed to use a three-column key to prevent data loss.
#go#mysql#data-import