Skip to content

Fix completion crash on plugin suggestions without default_args - #1285

Merged
lukaszsamson merged 1 commit into
masterfrom
fix-completion-plugin-suggestion-default-args
Oct 18, 2026
Merged

lukaszsamson merged 1 commit into
masterfrom
fix-completion-plugin-suggestion-default-args

Conversation

@lukaszsamson

Copy link
Copy Markdown
Collaborator

Completion crashed when a third party plugin returned a function/macro suggestion without the optional default_args key:

** (KeyError) key :default_args not found in:
    %{args: "value", arity: 1, name: "select", type: :function,
      origin: "Ash.Resource.Change.Builtins", args_list: ["value"], def_arity: 1, ...}
  completion.ex:596: anonymous fn/4 in Completion.maybe_reject_derived_functions/3
  completion.ex:280: Completion.completion/4

The suggestion has the old ElixirSense plugin shape (def_arity, args_list, origin, no default_args), supplied by a plugin loaded through ElixirSense.Plugin / ElixirLS.LanguageServer.Plugin. It is not emitted by Spark.ElixirSense.Plugin (spark 2.7.8 emits no function suggestions of this shape), so the exact emitting package is unconfirmed.

maybe_reject_derived_functions/3 now treats a missing default_args as 0. The other from_completion_item clauses pattern match on their keys and fall through to the catch-all clause, so they do not raise.

Adds a test with a fake plugin that emits this shape.

Third party ElixirSense-style plugins may emit function/macro suggestions
without the optional default_args key, which crashed
maybe_reject_derived_functions/3 with a KeyError. Treat a missing key as 0.
@lukaszsamson
lukaszsamson merged commit c418806 into master Oct 18, 2026
23 checks passed
@lukaszsamson
lukaszsamson deleted the fix-completion-plugin-suggestion-default-args branch October 18, 2026 21:58
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