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

500 response when requesting /api/currentuser caused by Babel #4744

Closed
1 of 4 tasks
crysxd opened this issue Mar 2, 2023 · 9 comments
Closed
1 of 4 tasks

500 response when requesting /api/currentuser caused by Babel #4744

crysxd opened this issue Mar 2, 2023 · 9 comments
Labels
triage This issue needs triage

Comments

@crysxd
Copy link
Contributor

crysxd commented Mar 2, 2023

The problem

As discussed on Discord: https://discord.com/channels/704958479194128507/705047010641838211/1080750696430841856
And in the forum: https://community.octoprint.org/t/http-500-when-trying-to-connect-to-the-api/50252

2023-03-02 06:41:25,493 - octoprint - ERROR - Exception on /api/currentuser [GET]
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/flask/app.py", line 2073, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python3.10/site-packages/flask/app.py", line 1519, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python3.10/site-packages/flask/app.py", line 1515, in full_dispatch_request
    rv = self.preprocess_request()
  File "/usr/lib/python3.10/site-packages/flask/app.py", line 1857, in preprocess_request
    rv = self.ensure_sync(before_func)()
  File "/usr/lib/python3.10/site-packages/octoprint/server/__init__.py", line 1427, in before_request
    g.locale = self._get_locale()
  File "/usr/lib/python3.10/site-packages/octoprint/server/__init__.py", line 1352, in _get_locale
    return Locale.parse(request.accept_languages.best_match(LANGUAGES))
  File "/usr/lib/python3.10/site-packages/babel/core.py", line 317, in parse
    raise TypeError(f"Unexpected value for identifier: {identifier!r}")
TypeError: Unexpected value for identifier: None

Did the issue persist even in safe mode?

Yes, it did persist

If you could not test in safe mode, please state why

No response

Version of OctoPrint

1.8.6

Operating system running OctoPrint

/

Printer model & used firmware incl. version

/

Browser and version of browser, operating system running browser

/

Checklist of files to include below

  • Systeminfo Bundle (always include!)
  • Contents of the JavaScript browser console (always include in cases of issues with the user interface)
  • Screenshots and/or videos showing the problem (always include in case of issues with the user interface)
  • GCODE file with which to reproduce (always include in case of issues with GCODE analysis or printing behaviour)

Additional information & file uploads

octoprint-systeminfo-20230301234452.zip

@github-actions github-actions bot added the triage This issue needs triage label Mar 2, 2023
@GitIssueBot
Copy link

This issue has been mentioned on OctoPrint Community Forum. There might be relevant details there:

https://community.octoprint.org/t/http-500-when-trying-to-connect-to-the-api/50252/2

@foosel
Copy link
Member

foosel commented Mar 2, 2023

Reason is most likely that we are blindly providing Local.parse with the result from request.accept_languages.best_match, and I guess that can be None. Not an issue so far, but Babel released 2.12 two days ago and apparently that no longer supports None. And since our version of Flask-Babel doesn't force an upper limit for Babel, and this was a minor version increase anyhow, this breaking issue was not expected at all and now here we are.

@foosel
Copy link
Member

foosel commented Mar 2, 2023

python-babel/babel@9b67367 is the commit that caused this behaviour change in Babel.

Note that the method signature even still says it accepts None. This is a breaking change in behaviour I certainly would not expect on a minor version upgrade 😕 Couldn't find it explicitly stated in the changelog either.

Guess I'll have to push 1.8.7 now 🙄

@foosel foosel closed this as completed in 59054cc Mar 2, 2023
@foosel
Copy link
Member

foosel commented Mar 2, 2023

1.8.7 is out

@Uro1
Copy link

Uro1 commented Mar 2, 2023

Note that the method signature even still says it accepts None. This is a breaking change in behaviour I certainly would not expect on a minor version upgrade 😕 Couldn't find it explicitly stated in the changelog either.

The CHANGES.rst of python-babel was bizarrely updated after the release (python-babel/babel#978) documenting the change after it was highlighted to them as a breaking-change by way of this issue 2 days ago (the same day 2.12.1 was released) - python-babel/babel#977

I would have thought any breaking-change would warrant a major version bump to highlight the change to the users of python-babel so those users can factor it in and update thier own code to handle the changes correctly.

@foosel
Copy link
Member

foosel commented Mar 2, 2023

Yes, so would I. I guess I need to add a version pin for Babel so this doesn't happen again, and make it fixed on minor versions since apparently they don't stick to semantic versioning 😕 Not the only dependency either. It's depressing how many libraries do no semantic versioning at all.

@NotReallyADeveloper
Copy link

As one who's running into this as well, I was happy to see a solution turned around quickly. Upgrading from the CLI didn't work, and it wasn't showing up in Stable, but setting to Maintenance RC showed the release as being available.

Anyhow, after installing the new version, I'm happy to say the error went away (I was having difficulty with Home Assistant and Octoprint integration not being able to get the API keys.

Thank you for the fix and the great software, too!

@cp2004
Copy link
Member

cp2004 commented Mar 2, 2023

it wasn't showing up in Stable, but setting to Maintenance RC showed the release as being available.

That's likely to do with the caching of the update checks - it can take up to 24 hours to come up 'normally', and then when you switch release channels a refresh is done instantly.

@NotReallyADeveloper
Copy link

Thanks. Not sure I'm completely out of the woods; while HA can now register the plugin, none of the devices are responding. I'll create a new issue.

AdamantLife added a commit to AdamantLife/OctoPrint-PrusaMK3S that referenced this issue Mar 9, 2023
commit 0fcb15d
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Tue Mar 7 10:50:21 2023 +0100

    Bump actions/upload-artifact from 1 to 3 (OctoPrint#4742)

    Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 1 to 3.
    - [Release notes](https://github.com/actions/upload-artifact/releases)
    - [Commits](actions/upload-artifact@v1...v3)

    ---
    updated-dependencies:
    - dependency-name: actions/upload-artifact
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 8e4c1f5
Merge: 7489b3c d813a0c
Author: Gina Häußge <gina@octoprint.org>
Date:   Thu Mar 2 16:07:26 2023 +0100

    Merge branch 'staging/bugfix'

commit d813a0c
Author: Charlie Powell <31997505+cp2004@users.noreply.github.com>
Date:   Mon May 30 10:04:51 2022 +0100

    :arrow_up: Bump wrapt to fix Python 3.11 compatibility (OctoPrint#4530)

    Fully tested on 3.7, 3.10 and 3.11 - any issues that did exist appear to have been resolved.

commit 7489b3c
Merge: fcb9eae 6e009d2
Author: Gina Häußge <gina@octoprint.org>
Date:   Thu Mar 2 15:58:56 2023 +0100

    Merge branch 'staging/bugfix'

commit 6e009d2
Author: Gina Häußge <gina@octoprint.org>
Date:   Thu Mar 2 15:51:32 2023 +0100

    🔖 Preparing release of 1.8.7

commit 59054cc
Author: Gina Häußge <gina@octoprint.org>
Date:   Thu Mar 2 15:34:39 2023 +0100

    🥅 Don't send `None` to `Locale.parse`

    The latest version of Babel no longer supports this
    but raises an error, which in turn leads to a
    500 Server Error response here.

    To fix this, we set a default for best_match.

    Closes OctoPrint#4744

commit fcb9eae
Author: Nick Mattis <nmattis@users.noreply.github.com>
Date:   Mon Feb 20 16:36:28 2023 -0500

    :pencil2: Minor updates to plugin getting started tutorial docs (OctoPrint#4736)

    * some minor updates to plugin getting started tutorial docs

    * fix helloworld to stay camelcase

commit b151152
Author: Patrick J. Ames <patrickames166@gmail.com>
Date:   Sat Feb 18 09:25:21 2023 -0500

    :pencil2: Fix small grammar error in README.md (OctoPrint#4731)

    "It also serves as central knowledge base" > "It also serves as a central knowledge base"

commit a1d95dd
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Fri Feb 10 13:08:19 2023 +0100

    Bump dessant/lock-threads from 2 to 4 (OctoPrint#4726)

    * Bump dessant/lock-threads from 2 to 4

    Bumps [dessant/lock-threads](https://github.com/dessant/lock-threads) from 2 to 4.
    - [Release notes](https://github.com/dessant/lock-threads/releases)
    - [Changelog](https://github.com/dessant/lock-threads/blob/master/CHANGELOG.md)
    - [Commits](dessant/lock-threads@v2...v4)

    ---
    updated-dependencies:
    - dependency-name: dessant/lock-threads
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...

    Signed-off-by: dependabot[bot] <support@github.com>

    * 👷‍♂️ Adjust input parameters

    Names changed in v3

    ---------

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    Co-authored-by: Gina Häußge <gina@octoprint.org>

commit c01216c
Author: Gina Häußge <gina@octoprint.org>
Date:   Fri Feb 10 13:03:10 2023 +0100

    👷‍♂️ Only trigger docs build on specific branches

    master, maintenance and devel only for now

commit a47b518
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Thu Feb 9 16:50:08 2023 +0000

    Bump robotology/gh-action-nightly-merge from 1.3.3 to 1.4.0

    Bumps [robotology/gh-action-nightly-merge](https://github.com/robotology/gh-action-nightly-merge) from 1.3.3 to 1.4.0.
    - [Release notes](https://github.com/robotology/gh-action-nightly-merge/releases)
    - [Commits](robotology/gh-action-nightly-merge@v1.3.3...v1.4.0)

    ---
    updated-dependencies:
    - dependency-name: robotology/gh-action-nightly-merge
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <support@github.com>

commit 40d71f1
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Thu Feb 9 16:50:00 2023 +0000

    Bump peter-evans/repository-dispatch from 1 to 2

    Bumps [peter-evans/repository-dispatch](https://github.com/peter-evans/repository-dispatch) from 1 to 2.
    - [Release notes](https://github.com/peter-evans/repository-dispatch/releases)
    - [Commits](peter-evans/repository-dispatch@v1...v2)

    ---
    updated-dependencies:
    - dependency-name: peter-evans/repository-dispatch
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...

    Signed-off-by: dependabot[bot] <support@github.com>

commit 3088c3b
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Thu Feb 9 18:00:54 2023 +0100

    Bump actions/labeler from 3 to 4 (OctoPrint#4727)

    Bumps [actions/labeler](https://github.com/actions/labeler) from 3 to 4.
    - [Release notes](https://github.com/actions/labeler/releases)
    - [Commits](actions/labeler@v3...v4)

    ---
    updated-dependencies:
    - dependency-name: actions/labeler
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit 135249c
Author: Gina Häußge <gina@octoprint.org>
Date:   Thu Feb 9 17:25:55 2023 +0100

    👷 Enable Dependabot for GitHub Actions

commit 814c3a1
Author: Gina Häußge <gina@octoprint.org>
Date:   Wed Feb 8 16:20:42 2023 +0100

    👷 Migrate from set-output got $GITHUB_OUTPUT

commit 68191cf
Author: Gina Häußge <gina@octoprint.org>
Date:   Wed Jan 18 17:38:26 2023 +0100

    💚 HTTP has \r\n line endings

    So we need to strip \r, \n already gets taken care of
    by the whole pipe. Also limit to first location header
    just in case.

commit c5b56ae
Author: Gina Häußge <gina@octoprint.org>
Date:   Wed Jan 18 17:15:30 2023 +0100

    👷 Get rid of newline in version

commit cc47b41
Author: Gina Häußge <gina@octoprint.org>
Date:   Wed Jan 18 17:06:43 2023 +0100

    👷 Fetch latest release without any action

    bash, curl, awk ftw

commit 397de4e
Author: Gina Häußge <gina@octoprint.org>
Date:   Wed Jan 18 16:47:37 2023 +0100

    👷 Use original get-latest-release action

commit 9179545
Author: Gina Häußge <gina@octoprint.org>
Date:   Mon Dec 19 14:33:41 2022 +0100

    📝 Get rid of Twitter link, fix build status badge

commit 7659c81
Author: Gina Häußge <gina@octoprint.org>
Date:   Wed Nov 16 14:46:25 2022 +0100

    🚨 Fix pre-commit's flake8 location

commit 7d336bd
Author: Gina Häußge <gina@octoprint.org>
Date:   Sat Nov 12 14:53:19 2022 +0100

    📝 Thou shall test in safe mode before opening bug reports

commit 588a1c4
Author: Gina Häußge <gina@octoprint.org>
Date:   Tue Oct 18 11:44:07 2022 +0200

    🔖 staging/bugfix is now 1.8.7.dev
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
triage This issue needs triage
Projects
Status: Done
Development

No branches or pull requests

6 participants