Skip to content

Write . for an empty package.json name or version - #507

Open
ankitjain91 wants to merge 1 commit into
sourcegraph:mainfrom
ankitjain91:fix/empty-package-fields
Open

ankitjain91 wants to merge 1 commit into
sourcegraph:mainfrom
ankitjain91:fix/empty-package-fields

Conversation

@ankitjain91

@ankitjain91 ankitjain91 commented Oct 12, 2026 •

Copy link
Copy Markdown

A package.json with "name": "" or "version": "" makes scip-typescript write an empty package field:

scip-typescript npm  1.0.0 src/`main.ts`/main().

The SCIP grammar reads a double space as an escaped space, so SCIP consumers misparse every symbol in that package. For example, Glean's scip-to-glean parses npm 1.0.0 as the manager and the descriptor path as the package name. It then stores an empty symbol name for every first-party symbol, so a lookup by name finds nothing.

ScipSymbol.package now writes . for an empty field, as the SCIP spec requires. A package.json with no name already gave . . through anonymousPackage(), so this makes the empty-string case match.

Test plan

  • New snapshot fixture empty-package-fields: the root package.json has "name": "", and src/version/package.json has "version": "".
    • Before the fix: definition 1.0.0 src/main.ts/ and definition empty-version lib.ts/.
    • After the fix: definition . 1.0.0 src/main.ts/ and definition empty-version . lib.ts/.
  • npm run build, npm run test (36 passed), npm run prettier-check, and npm run eslint pass. No other snapshot changes.

A package.json with `"name": ""` or `"version": ""` made scip-typescript
write an empty package field, for example
`scip-typescript npm  1.0.0 src/`main.ts`/main().`. The SCIP grammar reads
a double space as an escaped space, so SCIP consumers misparse every
symbol in that package. scip-to-glean, for example, stores an empty
symbol name for each one.

ScipSymbol.package now writes `.` for an empty field, as the SCIP spec
requires. A package.json without a name already gave `. .`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant