Skip to content

Conversation

@vinistock
Copy link
Member

@vinistock vinistock commented Jul 11, 2025

Motivation

If a user is typing a require_relative in an unsaved file, we have no way of providing completion since we don't know where the user intends to save the file and the path needs to be relative to that.

This currently crashes the request, but we can simply protect the code from this and return empty completions.

Implementation

Started returning early if the full_path of the URI is nil (which means the file is unsaved and we don't know what the file system path is).

Automated Tests

Added a test that reproduces the same crash.

Copy link
Member Author


How to use the Graphite Merge Queue

Add the label graphite-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@vinistock vinistock self-assigned this Jul 11, 2025
@vinistock vinistock added bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes labels Jul 11, 2025 — with Graphite App
@vinistock vinistock requested a review from egiurleo July 11, 2025 20:13
@vinistock vinistock marked this pull request as ready for review July 11, 2025 20:13
@vinistock vinistock requested a review from a team as a code owner July 11, 2025 20:13
@graphite-app
Copy link

graphite-app bot commented Jul 11, 2025

Merge activity

### Motivation

If a user is typing a `require_relative` in an unsaved file, we have no way of providing completion since we don't know where the user intends to save the file and the path needs to be relative to that.

This currently crashes the request, but we can simply protect the code from this and return empty completions.

### Implementation

Started returning early if the `full_path` of the URI is `nil` (which means the file is unsaved and we don't know what the file system path is).

### Automated Tests

Added a test that reproduces the same crash.
@graphite-app graphite-app bot force-pushed the 07-11-prevent_relative_require_completion_for_unsaved_files branch from 8d2c871 to ccfd63b Compare July 11, 2025 21:06
@graphite-app graphite-app bot merged commit ccfd63b into main Jul 11, 2025
36 checks passed
@graphite-app graphite-app bot deleted the 07-11-prevent_relative_require_completion_for_unsaved_files branch July 11, 2025 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix This PR will fix an existing bug server This pull request should be included in the server gem's release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants