Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mavrickrishi = "mavrickrishi" # Username
mavrick = "mavrick" # Username
inh = "inh" # Option in setpriv command
exportfs = "exportfs" # nfs related binary
ba = "ba" # sed branch command in :a;N;$!ba pattern

[files]
extend-exclude = ["registry/coder/templates/aws-devcontainer/architecture.svg"] #False positive
18 changes: 9 additions & 9 deletions registry/coder/modules/code-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Automatically install [code-server](https://github.com/coder/code-server) in a w
module "code-server" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/code-server/coder"
version = "1.5.0"
version = "1.5.1"
agent_id = coder_agent.example.id
}
```
Expand All @@ -29,7 +29,7 @@ module "code-server" {
module "code-server" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/code-server/coder"
version = "1.5.0"
version = "1.5.1"
agent_id = coder_agent.example.id
install_version = "4.106.3"
}
Expand All @@ -43,7 +43,7 @@ Install the Dracula theme from [OpenVSX](https://open-vsx.org/):
module "code-server" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/code-server/coder"
version = "1.5.0"
version = "1.5.1"
agent_id = coder_agent.example.id
extensions = [
"dracula-theme.theme-dracula"
Expand All @@ -61,7 +61,7 @@ Configure VS Code's [settings.json](https://code.visualstudio.com/docs/getstarte
module "code-server" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/code-server/coder"
version = "1.5.0"
version = "1.5.1"
agent_id = coder_agent.example.id
extensions = ["dracula-theme.theme-dracula"]
settings = {
Expand All @@ -78,7 +78,7 @@ Install multiple extensions from [OpenVSX](https://open-vsx.org/) by adding them
module "code-server" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/code-server/coder"
version = "1.5.0"
version = "1.5.1"
agent_id = coder_agent.example.id
extensions = ["dracula-theme.theme-dracula", "ms-azuretools.vscode-docker"]
}
Expand All @@ -92,7 +92,7 @@ Open a [`.code-workspace`](https://coder.com/docs/code-server/FAQ#how-does-code-
module "code-server" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/code-server/coder"
version = "1.5.0"
version = "1.5.1"
agent_id = coder_agent.example.id
workspace = "/home/coder/project/my.code-workspace"
}
Expand All @@ -106,7 +106,7 @@ You can pass additional command-line arguments to code-server using the `additio
module "code-server" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/code-server/coder"
version = "1.5.0"
version = "1.5.1"
agent_id = coder_agent.example.id
additional_args = "--disable-workspace-trust"
}
Expand All @@ -122,7 +122,7 @@ Run an existing copy of code-server if found, otherwise download from GitHub:
module "code-server" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/code-server/coder"
version = "1.5.0"
version = "1.5.1"
agent_id = coder_agent.example.id
use_cached = true
extensions = ["dracula-theme.theme-dracula", "ms-azuretools.vscode-docker"]
Expand All @@ -135,7 +135,7 @@ Just run code-server in the background, don't fetch it from GitHub:
module "code-server" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/code-server/coder"
version = "1.5.0"
version = "1.5.1"
agent_id = coder_agent.example.id
offline = true
}
Expand Down
15 changes: 13 additions & 2 deletions registry/coder/modules/code-server/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ for extension in "$${EXTENSIONLIST[@]}"; do
fi
done

# Strip JSONC features (block/line comments, trailing commas) for jq parsing
strip_jsonc_for_extensions() {
sed 's|//.*||g' "$1" | sed -E '
:a
N
$!ba
s#/[*]([^*]|[*]+[^*/])*[*]+/##g
Comment thread
DevelopmentCats marked this conversation as resolved.
s/,[^]}"]*([]}])/\1/g
'
Comment thread
DevelopmentCats marked this conversation as resolved.
}
Comment on lines +119 to +128

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P1 — sed 's|//.*||g' runs before block-comment removal; two silent failures result.

  1. Inline block comment containing :// — a line like /* https://open-vsx.org */ has //open-vsx.org */ stripped by stage 1, leaving /* https: in the buffer. Stage 2 finds no closing */ and passes the fragment through. jq then fails with parse error: Invalid numeric literal — zero extensions installed, nothing printed to the user. Verified locally.

  2. URL-valued settings in .code-workspace files"http.proxy": "https://proxy.corp:8080" becomes "http.proxy": "https: (unclosed string literal). jq exits with Invalid string: control characters from U+0000 through U+001F must be escaped. Same silent failure. Verified locally.

The suggestion merges into a single sed -E pass with block comments removed first. s#//[^\n]*##g then handles line comments on the slurped buffer — [^\n]* stops at each embedded newline, so it is equivalent to per-line stripping without a separate process. This fixes failure #1. Failure #2 (URL string values) is a fundamental limit of the regex approach — only a JSONC-aware parser can reliably distinguish // inside a string from // in a comment.

Suggested change
# Strip JSONC features (block/line comments, trailing commas) for jq parsing
strip_jsonc_for_extensions() {
sed 's|//.*||g' "$1" | sed -E '
:a
N
$!ba
s#/[*]([^*]|[*]+[^*/])*[*]+/##g
s/,[^]}"]*([]}])/\1/g
'
}
# Strip JSONC features (block/line comments, trailing commas) for jq parsing
strip_jsonc_for_extensions() {
sed -E '
:a
N
$!ba
s#/[*]([^*]|[*]+[^*/])*[*]+/##g
s#//[^\n]*##g
s/,[^]}"]*([]}])/\1/g
' "$1"
}

Generated by Coder Agents on behalf of @35C4n0r.


if [ "${AUTO_INSTALL_EXTENSIONS}" = true ]; then
if ! command -v jq > /dev/null; then
echo "jq is required to install extensions from a workspace file."
Expand Down Expand Up @@ -143,8 +154,8 @@ if [ "${AUTO_INSTALL_EXTENSIONS}" = true ]; then

if [ -n "$RECOMMENDATIONS_FILE" ]; then
printf "🧩 Installing extensions from %s...\n" "$RECOMMENDATIONS_FILE"
# Use sed to remove single-line comments before parsing with jq
extensions=$(sed 's|//.*||g' "$RECOMMENDATIONS_FILE" | jq -r "$RECOMMENDATIONS_QUERY")
# Strip JSONC comments and trailing commas before parsing with jq
extensions=$(strip_jsonc_for_extensions "$RECOMMENDATIONS_FILE" | jq -r "$RECOMMENDATIONS_QUERY")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P1 — code-server null-safety gap in RECOMMENDATIONS_QUERY

This PR upgrades vscode-web to use a null-safe query:

# vscode-web/run.sh (this PR)
RECOMMENDATIONS_QUERY='(.recommendations // [])[]'

but code-server was not updated in parallel. The query at line 137 of code-server/run.sh is still:

RECOMMENDATIONS_QUERY=".recommendations[]"

A valid extensions.json with no recommendations key at all (permitted by the VS Code schema) causes jq to emit null | .[] which exits non-zero — silently discarding all extension installations on code-server while vscode-web handles the same file cleanly.

Fix (line 137, not in the diff hunk above — apply manually):

- RECOMMENDATIONS_QUERY=".recommendations[]"
+ RECOMMENDATIONS_QUERY='(.recommendations // [])[]'

Note the single-quote change: the expression contains no shell variables, so single quotes are correct and prevent accidental expansion.

Generated by Coder Agents on behalf of @35C4n0r.

for extension in $extensions; do
if extension_installed "$extension"; then
continue
Expand Down
12 changes: 6 additions & 6 deletions registry/coder/modules/vscode-web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Automatically install [Visual Studio Code Server](https://code.visualstudio.com/
module "vscode-web" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/vscode-web/coder"
version = "1.6.0"
version = "1.6.1"
agent_id = coder_agent.example.id
accept_license = true
}
Expand All @@ -30,7 +30,7 @@ module "vscode-web" {
module "vscode-web" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/vscode-web/coder"
version = "1.6.0"
version = "1.6.1"
agent_id = coder_agent.example.id
install_prefix = "/home/coder/.vscode-web"
folder = "/home/coder"
Expand All @@ -44,7 +44,7 @@ module "vscode-web" {
module "vscode-web" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/vscode-web/coder"
version = "1.6.0"
version = "1.6.1"
agent_id = coder_agent.example.id
extensions = ["github.copilot", "ms-python.python", "ms-toolsai.jupyter"]
accept_license = true
Expand All @@ -59,7 +59,7 @@ Configure VS Code's [Machine settings.json](https://code.visualstudio.com/docs/g
module "vscode-web" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/vscode-web/coder"
version = "1.6.0"
version = "1.6.1"
agent_id = coder_agent.example.id
extensions = ["dracula-theme.theme-dracula"]
settings = {
Expand All @@ -80,7 +80,7 @@ By default, this module installs the latest. To pin a specific version, retrieve
module "vscode-web" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/vscode-web/coder"
version = "1.6.0"
version = "1.6.1"
agent_id = coder_agent.example.id
commit_id = "e54c774e0add60467559eb0d1e229c6452cf8447"
accept_license = true
Expand All @@ -96,7 +96,7 @@ Note: Either `workspace` or `folder` can be used, but not both simultaneously. T
module "vscode-web" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder/vscode-web/coder"
version = "1.6.0"
version = "1.6.1"
agent_id = coder_agent.example.id
workspace = "/home/coder/coder.code-workspace"
}
Expand Down
18 changes: 15 additions & 3 deletions registry/coder/modules/vscode-web/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,26 @@ for extension in "$${EXTENSIONLIST[@]}"; do
fi
done

# Strip JSONC features (block/line comments, trailing commas) for jq parsing
strip_jsonc_for_extensions() {
sed 's|//.*||g' "$1" | sed -E '
:a
N
$!ba
s#/[*]([^*]|[*]+[^*/])*[*]+/##g
s/,[^]}"]*([]}])/\1/g
Comment thread
DevelopmentCats marked this conversation as resolved.
'
Comment thread
DevelopmentCats marked this conversation as resolved.
}
Comment on lines +153 to +162

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P1 — URL corruption / single-line file: stage ordering is wrong

The current implementation pipes through a line-comment stripper before slurping into a multi-line buffer:

sed 's|//.*||g' "$1" | sed -E '
  :a
  N
  $!ba
  s#/[*]([^*]|[*]+[^*/])*[*]+/##g
  ...

Two verified failure modes:

  1. URL inside a block comment/* https://open-vsx.org */: stage 1 strips ://open-vsx.org */, leaving /* https: unclosed. Stage 2's block-comment regex can't match, jq receives garbage and exits non-zero — zero extensions installed, no error surfaced.

  2. URL-valued setting"http.proxy": "https://proxy.corp": stage 1 strips ://proxy.corp", producing an unclosed string literal. jq exits 5, zero extensions installed silently.

  3. Single-line input:a;N;$!ba exits immediately at EOF without running any substitution (GNU sed behaviour on last-line N). A one-line {"recommendations":["ext1",]} is passed through unchanged and jq fails on the trailing comma.

Fix: slurp the whole file first, then strip block comments, then line comments — in a single sed invocation:

Suggested change
# Strip JSONC features (block/line comments, trailing commas) for jq parsing
strip_jsonc_for_extensions() {
sed 's|//.*||g' "$1" | sed -E '
:a
N
$!ba
s#/[*]([^*]|[*]+[^*/])*[*]+/##g
s/,[^]}"]*([]}])/\1/g
'
}
strip_jsonc_for_extensions() {
sed -E '
:a
N
$!ba
s#/[*]([^*]|[*]+[^*/])*[*]+/##g
s#//[^\n]*##g
s/,[^]}"]*([]}])/\1/g
' "$1"
}

s#//[^\n]*##g is safe on the slurped buffer because [^\n]* stops at each embedded newline, so it only strips to end-of-line.

Generated by Coder Agents on behalf of @35C4n0r.


if [ "${AUTO_INSTALL_EXTENSIONS}" = true ]; then
if ! command -v jq > /dev/null; then
echo "jq is required to install extensions from a workspace file."
else
# Prefer WORKSPACE if set and points to a file
if [ -n "${WORKSPACE}" ] && [ -f "${WORKSPACE}" ]; then
printf "🧩 Installing extensions from %s...\n" "${WORKSPACE}"
# Strip single-line comments then parse .extensions.recommendations[]
extensions=$(sed 's|//.*||g' "${WORKSPACE}" | jq -r '(.extensions.recommendations // [])[]')
extensions=$(strip_jsonc_for_extensions "${WORKSPACE}" \
| jq -r '(.extensions.recommendations // [])[]')
for extension in $extensions; do
$VSCODE_WEB "$EXTENSION_ARG" --install-extension "$extension" --force
done
Expand All @@ -170,7 +181,8 @@ if [ "${AUTO_INSTALL_EXTENSIONS}" = true ]; then
fi
if [ -f "$WORKSPACE_DIR/.vscode/extensions.json" ]; then
printf "🧩 Installing extensions from %s/.vscode/extensions.json...\n" "$WORKSPACE_DIR"
extensions=$(sed 's|//.*||g' "$WORKSPACE_DIR/.vscode/extensions.json" | jq -r '.recommendations[]')
extensions=$(strip_jsonc_for_extensions "$WORKSPACE_DIR/.vscode/extensions.json" \
| jq -r '(.recommendations // [])[]')
for extension in $extensions; do
$VSCODE_WEB "$EXTENSION_ARG" --install-extension "$extension" --force
done
Expand Down
Loading