Skip to content

The origin field does not restrict URLs#36

Merged
BretRen merged 1 commit into
mainfrom
feat/origin-not-restrict-url
Apr 20, 2026
Merged

The origin field does not restrict URLs#36
BretRen merged 1 commit into
mainfrom
feat/origin-not-restrict-url

Conversation

@BretRen
Copy link
Copy Markdown
Member

@BretRen BretRen commented Apr 20, 2026

IMPORTANT
This includes a destructive update; all previous origins will be lost.

Summary by CodeRabbit

  • Bug Fixes
    • Updated the character origin field in creation and editing forms to accept general text input instead of URL-only format, allowing users greater flexibility when entering character information.
    • Improved placeholder guidance in character origin input fields across the application, displaying clearer direction for user input.

@BretRen BretRen linked an issue Apr 20, 2026 that may be closed by this pull request
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

📝 Walkthrough

Walkthrough

A PocketBase migration converts the origin field in the characters collection from a URL type to a text type, with corresponding placeholder text updates in two UI components to reflect the new field purpose.

Changes

Cohort / File(s) Summary
Database Migration
migrations/1776711295_updated_characters.go
Migration registers up/down handlers for collection pbc_3298390430. Up path: removes url field url3740358174 and inserts text field text3740358174 (named origin) at index 6. Down path: reverses the change by removing the text field and re-adding the url field at index 3.
UI Placeholder Updates
website/src/lib/components/CharacterCreateModal.svelte, website/src/routes/edit/characters/[id]/+page.svelte
Changed origin field placeholder text from https://pdnode.com to Pdnode CPs in character creation and edit dialogs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • pdnode-team/cp#5: Modifies the same characters collection (pbc_3298390430) and origin field schema, likely preceding or related to this migration.

Poem

🐰 From URL to text, a hop we make,
Origin fields for goodness sake,
Pdnode CPs now take the stage,
A schema change upon the page!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main technical change: converting the origin field from a URL type to a text type to remove URL restrictions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/origin-not-restrict-url

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the character origin field from a URL type to a text type, including a database migration and UI placeholder updates. The review feedback highlights a potential data loss issue caused by changing the field ID during the migration and notes an inconsistency in the field indexing between the up and down migration functions.

Comment thread migrations/1776711295_updated_characters.go
Comment thread migrations/1776711295_updated_characters.go
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
migrations/1776711295_updated_characters.go (1)

15-32: Add a repair plan for the destructive required-field reset.

Line 16 drops all existing origin values, then lines 19-32 add origin back as required. Existing records will be left without a required value until manually repaired, so please pair this with an export/backup and post-migration backfill plan if this reaches shared data.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@migrations/1776711295_updated_characters.go` around lines 15 - 32, This
migration currently removes field id "url3740358174" then re-adds a new field id
"text3740358174" named "origin" with "required": true which will orphan existing
records; before applying, export/backup data and change the migration to (1) add
the new field "text3740358174" with required:false (or a default value) using
collection.Fields.AddMarshaledJSONAt, (2) run a backfill step that copies values
from the old field id "url3740358174" into the new field for all records (or
computes a safe default), and only after successful backfill update the field to
required:true (or remove the old field) so no records are left invalid; include
these steps/comments in the migration and ensure the migration process performs
an export/backup prior to destructive RemoveById.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@migrations/1776711295_updated_characters.go`:
- Around line 43-59: The down migration currently adds the new origin field via
collection.Fields.AddMarshaledJSONAt(3, ...) with id "url3740358174" before
removing the old origin field "text3740358174", causing a temporary duplicate
name; change the order so you call
collection.Fields.RemoveById("text3740358174") first, then call
collection.Fields.AddMarshaledJSONAt(3, []byte(...)) to add the url field (id
"url3740358174") to ensure the old field is removed before the new one is
created.

---

Nitpick comments:
In `@migrations/1776711295_updated_characters.go`:
- Around line 15-32: This migration currently removes field id "url3740358174"
then re-adds a new field id "text3740358174" named "origin" with "required":
true which will orphan existing records; before applying, export/backup data and
change the migration to (1) add the new field "text3740358174" with
required:false (or a default value) using collection.Fields.AddMarshaledJSONAt,
(2) run a backfill step that copies values from the old field id "url3740358174"
into the new field for all records (or computes a safe default), and only after
successful backfill update the field to required:true (or remove the old field)
so no records are left invalid; include these steps/comments in the migration
and ensure the migration process performs an export/backup prior to destructive
RemoveById.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dc902a18-8103-4eba-b53c-63a6a650977f

📥 Commits

Reviewing files that changed from the base of the PR and between 01f31ac and 864fe7c.

📒 Files selected for processing (3)
  • migrations/1776711295_updated_characters.go
  • website/src/lib/components/CharacterCreateModal.svelte
  • website/src/routes/edit/characters/[id]/+page.svelte

Comment on lines +43 to +59
// add field
if err := collection.Fields.AddMarshaledJSONAt(3, []byte(`{
"exceptDomains": [],
"hidden": false,
"id": "url3740358174",
"name": "origin",
"onlyDomains": [],
"presentable": false,
"required": true,
"system": false,
"type": "url"
}`)); err != nil {
return err
}

// remove field
collection.Fields.RemoveById("text3740358174")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat migrations/1776711295_updated_characters.go

Repository: pdnode-team/cp

Length of output: 1354


Reorder down migration to remove the text field before adding origin field.

The down migration currently adds a second origin field (url3740358174) before removing the existing origin field (text3740358174), creating a temporary duplicate field name that violates schema validation. Reverse the order: remove text3740358174 first, then add the url field. This mirrors proper rollback semantics and prevents migration failure on rollback.

Rollback ordering fix
 		// remove field
+		collection.Fields.RemoveById("text3740358174")
+
+		// add field
 		if err := collection.Fields.AddMarshaledJSONAt(3, []byte(`{
 			"exceptDomains": [],
 			"hidden": false,
 			"id": "url3740358174",
 			"name": "origin",
 			"onlyDomains": [],
 			"presentable": false,
 			"required": true,
 			"system": false,
 			"type": "url"
 		}`)); err != nil {
 			return err
 		}
-
-		// remove field
-		collection.Fields.RemoveById("text3740358174")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@migrations/1776711295_updated_characters.go` around lines 43 - 59, The down
migration currently adds the new origin field via
collection.Fields.AddMarshaledJSONAt(3, ...) with id "url3740358174" before
removing the old origin field "text3740358174", causing a temporary duplicate
name; change the order so you call
collection.Fields.RemoveById("text3740358174") first, then call
collection.Fields.AddMarshaledJSONAt(3, []byte(...)) to add the url field (id
"url3740358174") to ensure the old field is removed before the new one is
created.

@BretRen BretRen merged commit 0505c40 into main Apr 20, 2026
1 check passed
@BretRen BretRen deleted the feat/origin-not-restrict-url branch April 20, 2026 19:02
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.

The origin field does not restrict URLs.

1 participant