Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 8, 2025

When creating or releasing documents without explicitly providing a slug, __rerum.slug was being set to "" instead of null. This created ambiguity between "no slug" and "empty string slug".

Changes

  • controllers/crud.js: Initialize slug to null instead of ""
  • controllers/release.js: Initialize slug to null instead of ""

The slug is only assigned a string value when the Slug header is explicitly provided. Otherwise, documents now have __rerum.slug: null, clarifying that no custom slug was set.

// Before
let slug = ""
if(req.get("Slug")){
    slug = slug_json.slug_id
}
rerumProp.__rerum.slug = slug  // "" when no Slug header

// After  
let slug = null
if(req.get("Slug")){
    slug = slug_json.slug_id
}
rerumProp.__rerum.slug = slug  // null when no Slug header

Existing MongoDB queries using {"$or":[{"_id": id}, {"__rerum.slug": id}]} continue to work correctly.

Original prompt

This section details on the original issue you should resolve

<issue_title>Prevent slug from ever being empty</issue_title>
<issue_description>Two ways to call a document: _id or __rerum.slug both are always unique. However, if the call is not specifically creating or updating a slug, it should not be sent. The default ought to be null not "".</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: cubap <1119165+cubap@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix slug to default to null instead of empty string Set slug default to null instead of empty string Dec 8, 2025
Copilot AI requested a review from cubap December 8, 2025 21:40
@cubap cubap marked this pull request as ready for review December 8, 2025 21:41
@cubap cubap requested a review from thehabes as a code owner December 8, 2025 21:41
Copy link
Member

@thehabes thehabes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is best

@thehabes thehabes merged commit 9db5012 into main Dec 8, 2025
4 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.

Prevent slug from ever being empty

3 participants