Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress notifications does not contain the field kind #217

Closed

Conversation

MatejKastak
Copy link
Contributor

WorkDoneProgress* fields kind are excluded when sending to client(editor)

  • I think this originated from migration to pydantic
  • WorkDoneProgressBegin has field kind with default value 'begin' @ code
  • this eventually generates notification @ code
  • however the problem is here when model is serialized to json
            body = data.json(by_alias=True, exclude_unset=True, encoder=default_serializer)
  • exclude_unset causes the object to ignore kind = 'begin' since it was initialized with default value -- docs
  • this is better illustrated in the logs section bellow

Logs

Python code here in the example json-server:

    ls.progress.begin(token, WorkDoneProgressBegin(title='Scan', percentage=0))

Generates the following. Notice how WorkDoneProgressBegin contains kind='begin' (line 1), however the data send does not contain this field (params->value->kind?) (line 2).

Sending notification: "$/progress" token='token' value=WorkDoneProgressBegin(kind='begin', title='Scan', cancellable=None, message=None, percentage=0)
Sending data: {"jsonrpc": "2.0", "method": "$/progress", "params": {"token": "token", "value": {"title": "Scan", "percentage": 0}}}

Solution?

  • all of the WorkDoneProgress* messages are affected by this issue
  • workaround is to pass kind explicitly, like this PR shows
  • I am not sure why we are excluding unset fields.. maybe the solution is to remove exclude_unset option, however this might cause more problems (I am sure there was a reason to put this option there in the first place)
  • What do you think? (this PR does not have to be merged, it can be viewed as a demonstration of the problem)

Repro

  1. Open json example server
  2. Start progress command
  3. Observe that there is no task running at the bottom of the window (with name "indexing")

After this PR:

  1. Open json example server
  2. Start progress command
  3. Indexing task is shown

Code review checklist (for code reviewer to complete)

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
  • Title summarizes what is changing
  • Commit messages are meaningful (see this for details)
  • Tests have been included and/or updated, as appropriate
  • Docstrings have been included and/or updated, as appropriate
  • Standalone docs have been updated accordingly
  • CONTRIBUTORS.md was updated, as appropriate
  • Changelog has been updated, as needed (see CHANGELOG.md)

@perrinjerome
Copy link
Contributor

Ah this is same as #231

tombh added a commit that referenced this pull request May 31, 2022
This addresses #217 and #231.

I am still new to the project, so I may not have the full story. But it
started with a somewhat far-reaching merge to remove defaults from all
serialisable fields in the API: #198. This had the knock-on effect of
regressing progress notifications, as reported by @MatejKastak in #217.
One of their suggestions is to not use `exclude_unset=True`. Some months
later @dimbleby suggested that `exclude_none=True` would also fix the
issue[1]. Considering those 2 suggestions, let's replace
`exclude_unset=True` with `exclude_none=True`.

1. #198 (comment)
tombh added a commit that referenced this pull request May 31, 2022
This addresses #217 and #231.

I am still new to the project, so I may not have the full story. But it
started with a somewhat far-reaching merge to remove defaults from all
serialisable fields in the API: #198. This had the knock-on effect of
regressing progress notifications, as reported by @MatejKastak in #217.
One of their suggestions is to not use `exclude_unset=True`. Some months
later @dimbleby suggested that `exclude_none=True` would also fix the
issue[1]. Considering those 2 suggestions, let's replace
`exclude_unset=True` with `exclude_none=True`.

1. #198 (comment)
tombh added a commit that referenced this pull request May 31, 2022
This addresses #217 and #231.

I am still new to the project, so I may not have the full story. But it
started with a somewhat far-reaching merge to remove defaults from all
serialisable fields in the API: #198. This had the knock-on effect of
regressing progress notifications, as reported by @MatejKastak in #217.
One of their suggestions is to not use `exclude_unset=True`. Some months
later @dimbleby suggested that `exclude_none=True` would also fix the
issue[1]. Considering those 2 suggestions, let's replace
`exclude_unset=True` with `exclude_none=True`.

1. #198 (comment)
tombh added a commit that referenced this pull request Jun 1, 2022
Fixes #217, #231.

I am still new to the project, so I may not have the full story. But it
started with a somewhat far-reaching merge to remove defaults from all
serialisable fields in the API: #198. This had the knock-on effect of
regressing progress notifications, as reported by @MatejKastak in #217.
One of their suggestions is to not use `exclude_unset=True`. Some months
later @dimbleby suggested that `exclude_none=True` would also fix the
issue[1]. Considering those 2 suggestions, let's replace
`exclude_unset=True` with `exclude_none=True`.

1. #198 (comment)
tombh added a commit that referenced this pull request Jun 1, 2022
Fixes #217, #231.

I am still new to the project, so I may not have the full story. But it
started with a somewhat far-reaching merge to remove defaults from all
serialisable fields in the API: #198. This had the knock-on effect of
regressing progress notifications, as reported by @MatejKastak in #217.
One of their suggestions is to not use `exclude_unset=True`. Some months
later @dimbleby suggested that `exclude_none=True` would also fix the
issue[1]. Considering those 2 suggestions, let's replace
`exclude_unset=True` with `exclude_none=True`.

1. #198 (comment)
tombh added a commit that referenced this pull request Jun 1, 2022
Fixes #217, #231.

I am still new to the project, so I may not have the full story. But it
started with a somewhat far-reaching merge to remove defaults from all
serialisable fields in the API: #198. This had the knock-on effect of
regressing progress notifications, as reported by @MatejKastak in #217.
One of their suggestions is to not use `exclude_unset=True`. Some months
later @dimbleby suggested that `exclude_none=True` would also fix the
issue[1]. Considering those 2 suggestions, let's replace
`exclude_unset=True` with `exclude_none=True`.

1. #198 (comment)
@tombh tombh closed this in 45879b4 Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants