uhd-urz / elAPI

An extensible API client for eLabFTW
GNU Affero General Public License v3.0
5 stars 0 forks source link

Auto-completion shows error message #15

Closed alexander-haller closed 3 months ago

alexander-haller commented 8 months ago

In GitLab by @mhxion on Feb 14, 2024, 18:13

Reported by @alexander-haller.

When pressing TAB for auto-completion, elapi also shows any unresolved error message along with the suggestions for auto-completions.

image

This is also reproducible on iTerm on MacOS which suggests this isn't necessarily a terminal issue.

alexander-haller commented 8 months ago

In GitLab by @mhxion on Feb 14, 2024, 18:42

After some quick tests, I think I know why. This turns out to be much of larger issue stemming from some unrefactored code in src/elapi/configuration/config.py.

  1. The bash/zsh script for elapi auto-completion calls elapi --help.
  2. Which calls the CLI interface APIs (provided by a third-party library typer which also provides the auto-completion bash/zsh script) from src/elapi/cli/elapi.py.
  3. Which in turn calls some essential configuration variables (like APP_NAME == "elapi") from src/elapi/configuration/config.py.
  4. config.py prints any critical error message (if those errors exist) to STDERR as a priority before continuing with anything else.
  5. Thus, the error messages are shown anytime the command elapi is invoked in any way!

The best solution would be to refactor config.py such that the error messages aren't really printed anytime elapi command is run. config.py also requires refactoring to allow for elapi plugins to make use of elapi.yml, e.g., if a third-party developer writing an elapi plugin (and any script using the elapi package would be a valid elapi plugin!) wants to add their own key: value in elapi.yml. Doing the latter would solve this bug as well. However, that would take some work that maybe we can set to do at a later time.

alexander-haller commented 7 months ago

In GitLab by @mhxion on Mar 19, 2024, 02:05

mentioned in commit 603cd4e4a662a81860fb46c4c8a9e1d390530c1c

alexander-haller commented 7 months ago

In GitLab by @mhxion on Mar 21, 2024, 02:07

Partially fixed in https://gitlab.urz.uni-heidelberg.de/urz-elabftw/elapi/-/commit/603cd4e4a662a81860fb46c4c8a9e1d390530c1c.

alexander-haller commented 4 months ago

In GitLab by @mhxion on Jun 15, 2024, 13:07

Actually it is fixed.