Skip to content

fix(server): validate title field in POST /api/projects - #39

Closed
Jah-yee wants to merge 1 commit into
safiware:mainfrom
Jah-yee:fix/project-title-validation
Closed

Jah-yee wants to merge 1 commit into
safiware:mainfrom
Jah-yee:fix/project-title-validation

Conversation

@Jah-yee

@Jah-yee Jah-yee commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

What

Adds the same title validation that PATCH /api/projects/:p already has to POST /api/projects.

Before: POST /api/projects accepted any title: 5,000-character strings, numbers, or only-spaces — stored as-is in the sidebar and command palette.

After: POST /api/projects now validates title the same way PATCH does: must be a string, 1-80 characters after .trim(), or omitted (falls back to repo/folder name). Invalid titles receive 400 a title is 1 to 80 characters, matching PATCH's error message.

Where

  • app/server/src/app.ts:169-172: added if guard + .trim() on stored value

Done

Fixes #35.

Adds the same validation that PATCH already has: title must be a
string, 1-80 characters after trimming, or omitted.

Without this, POST /api/projects accepted titles of any length,
only-spaces titles, or numeric titles, leading to malformed entries
in the sidebar and command palette.

Fixes safiware#35.
@vercel

vercel Bot commented Oct 6, 2026

Copy link
Copy Markdown

@Jah-yee is attempting to deploy a commit to the Tawab Safi's projects Team on Vercel.

A member of the Team first needs to authorize it.

asaficontact added a commit that referenced this pull request Oct 6, 2026
Adding a project checks its title as renaming does (closes #35; the fix from #39 by @Jah-yee)
@asaficontact

Copy link
Copy Markdown
Contributor

Thanks for this fix, @Jah-yee. It was right, and it is now in main through #43, with you credited as co-author (it closes #35).

We merged it through our own PR because archdraw needs two things on every contribution that this PR did not have:

  1. A test. Issue Validate the project title when a project is added #35 asks for one. Adding a project checks its title as renaming does (closes #35; the fix from #39 by @Jah-yee) #43 adds cases to server/test/app.test.ts: an over-long, blank, empty or non-text title is refused, a padded title is stored trimmed, and with no title the repo's name is used. The test fails without your change.
  2. A DCO sign-off on each commit (git commit -s). Under archdraw's license, the sign-off is how a contributor confirms they license their change to the project (see CONTRIBUTING.md), and the sign-off check fails without it.

With both, a PR like this can be merged as it is. Closing this one in favour of #43. Thanks again!

— Banna, one of Tawab's agents

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.

Validate the project title when a project is added

2 participants