Skip to content

Allow pasting cloud-init user data as text on instance create - #3419

Open
sudomateo wants to merge 1 commit into
mainfrom
user-data-textarea
Open

sudomateo wants to merge 1 commit into
mainfrom
user-data-textarea

Conversation

@sudomateo

Copy link
Copy Markdown
Member

Closes #3118

Adds a textarea for cloud-init user data on the instance create form, so users can paste user data instead of creating and uploading a file. A Paste text / Upload file radio above the input picks the source, and pasting is the default. File upload stays as an option because some user data (e.g., gzipped cloud-config) isn't plain text.

  • Only the selected source is submitted, so content left in the hidden input is ignored.
  • Both inputs stay mounted and only the inactive one is hidden, so switching back and forth keeps what was entered.
  • Pasted text is UTF-8 encoded and then base64-encoded, the same as an uploaded file. Empty or whitespace-only text sends no user_data.

Before

Before: file upload only

After

Paste text (default) Upload file
After: paste text After: upload file

Testing

  • npm run tsc and npm run lint pass.
  • Extended the can create an instance e2e test to type user data, switch to file upload and back, and check the text is preserved.
  • Checked the create request body manually with throwaway Playwright tests (not committed): non-ASCII text round-trips through base64, whitespace-only text omits user_data, file mode sends the file bytes and ignores typed text, and switching back to text after choosing a file sends the text.

@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
console Ready Ready Preview Oct 22, 2026 11:36pm UTC

Request Review

@sudomateo

Copy link
Copy Markdown
Member Author

@claude review

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I reviewed this PR and didn't find any bugs. It's a user-facing UX change (a new user data component, with pasted text as the new default), so a maintainer should still look at the design and accessibility choices.

What was reviewed:

  • The submit path in app/forms/instance-create.tsx: only the selected source gets encoded. Whitespace-only text and a missing file both leave userData undefined, and text goes through a Blob, so it is UTF-8 encoded before base64.
  • UserDataField wiring: FileInput gets the RHF field minus value, the same way FileField does. Its name/id props override the input's defaults. The uncontrolled RadioGroup default matches the 'text' form default, and nothing calls reset/setValue on these fields.
  • The leftover userData field has no other references, and the e2e test covers switching sources without losing the typed text.
Extended reasoning...

The change touches only the instance create form and its e2e test. It replaces the FileField for user data with a new UserDataField (radio, textarea and file input) and splits the form value into source, text and file fields. It has no auth, crypto or injection surface; user data is base64-encoded on the client the same way as before. The logic is small and looks correct. I deferred because it changes the default UX and adds a custom labelled control whose design and accessibility a maintainer may want to weigh. No CODEOWNERS file covers these paths, and the timeline shows no open reviewer objections.

@david-crespo
david-crespo marked this pull request as ready for review October 22, 2026 21:08
@david-crespo

david-crespo commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

The basic idea looks pretty good to me. Only things I might want to tweak are:

  • add some vertical spacing
  • how the form fields are hooked up (probably fine as-is)
  • worth considering a mono font for the text area

This branch was successfully deployed

1 active deployment
Preview — 533ebafe Deployed Oct 22, 2026 by vercel[bot]
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.

Specify cloud-init user-data via textarea

2 participants