Unable to save snippet with empty code
- Dominant language
- JavaScript
- Stars
- 6.5k
- Forks
- 772
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
It's not possible to save or update snippets when the code is empty.
I wanna bookmark them to paste the code later.
> Error: Unable to create snippet.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to https://astexplorer.net
2. Delete the placeholder code
3. Enable the babelv7 transform
4. Paste
```js
export default function (babel) {
const { types: t } = babel;
return {
name: "ast-transform", // not required
visitor: {
VariableDeclarator(path) {
const binding = path.scope.getBinding(path.node.id.name);
if (!binding) return;
if (!binding.constant) return;
if (!t.isLiteral(path.node.init)) return;
binding.referencePaths.forEach(ref => {
ref.replaceWith(path.node.init);
});
path.remove();
}
}
};
}
```
5. Click save
**Expected behavior**
Successfully create a snippet
**Screenshots**

**Browser (please complete the following information):**
- OS: Linux
- Browser Brave
- Version 1.61.104
**astexplorer settings:**
- Selected parser: `@babel/parser`
- Selected transformer (if applicable): `babelv7`
- Contents of the local storage key `explorerSettingsV1`:
```json
{
"showTransformPanel": true,
"parserSettings": {},
"parserPerCategory": {
"javascript": "babylon7"
},
"workbench": {
"parser": "babylon7",
"code": "",
"keyMap": "default",
"transform": {
"code": "export default function (babel) {\n const { types: t } = babel;\n \n return {\n name: \"ast-transform\", // not required\n visitor: {\n VariableDeclarator(path) {\n const binding = path.scope.getBinding(path.node.id.name);\n if (!binding) return;\n if (!binding.constant) return;\n if (!t.isLiteral(path.node.init)) return;\n binding.referencePaths.forEach(ref => {\n ref.replaceWith(path.node.init);\n });\n path.remove();\n }\n }\n };\n}\n",
"transformer": "babelv7"
}
}
}
```
**Additional context**
Response: 500 Internal Server Error - `Something went wrong`
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the failure at https://astexplorer.net by clearing the code, enabling the babelv7 transform, and saving the snippet. Inspect the save request and the handling of the reported 500 response; done means an empty-code snippet can be created and updated successfully while retaining the transform settings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- babel, javascript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100