[PR #497] [MERGED] String substitution throws TypeError, preventing VNC SSH Tunnel #673

Closed
opened 2026-02-27 16:40:06 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/retspen/webvirtmgr/pull/497
Author: @alexdo
Created: 2/7/2015
Status: Merged
Merged: 2/9/2015
Merged by: @retspen

Base: masterHead: hotfix/console-ssh-type-error


📝 Commits (3)

  • 95092f8 Fixes a TypeError just before SSH connect
  • 08af85b Adds reference to github PR #497 after creation
  • c63ff1a CS: Properly break line to stay within line length

📊 Changes

1 file changed (+7 additions, -4 deletions)

View changed files

📝 console/webvirtmgr-console (+7 -4)

📄 Description

Hi there,

I just came across an error regarding the noVNC console.
For security reasons, I only want VNC to listen on the loopback interface. In order to do so, I changed my connection type to SSH and set up authentication like described in the wiki.

However, I was unable to connect to the VMs Console via Webvirtmgr.
Skipping through the logs, I found the following exception:

WARNING:root:No local_settings file found.
WebSocket server settings:
  - Listen on 127.0.0.1:6080
  - Flash security policy server
  - SSL/TLS support
  - proxying from 127.0.0.1:6080 to ignore:ignore

...
  4: 127.0.0.1: Plain non-SSL (ws://) WebSocket connection
  4: 127.0.0.1: Version hybi-13, base64: 'False'
  4: Fail to open tunnel : not all arguments converted during string formatting
  4: handler exception: not all arguments converted during string formatting
  5: 127.0.0.1: Plain non-SSL (ws://) WebSocket connection
  5: 127.0.0.1: Version hybi-13, base64: 'False'
  5: Fail to open tunnel : not all arguments converted during string formatting
  5: handler exception: not all arguments converted during string formatting
^C  6: Got SIGINT, exiting
In SystemExit

Strangely, not all arguments converted during string formatting is a TypeError occuring during sprintf-like functions.
Digging into console/webvirtmgr-console I tracked the error back to the following block:

                self.msg("Try to open tunnel on %s@%s:%s on console %s:%s " +
                         "(or socket %s)" %
                         (connuser, connhost, connport, console_host,
                          console_port, console_socket))

Unfortunately, string substitution won't work here. Python substitutes the placeholders first, connects the string afterwards. As a result, a TypeError is thrown because six variables are supplied for a string with only one placeholder.

I noticed you strictly use 80 chars per line at max, so my approach is to save the debug message into a variable error_msg, which will then be substituted with placeholders during the call to self.msg.

Feel free to change this however you think would be a better style. These are probably the only three lines of Python I've written in the last five years 😉

Cheers, 🍻
Alexander


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/retspen/webvirtmgr/pull/497 **Author:** [@alexdo](https://github.com/alexdo) **Created:** 2/7/2015 **Status:** ✅ Merged **Merged:** 2/9/2015 **Merged by:** [@retspen](https://github.com/retspen) **Base:** `master` ← **Head:** `hotfix/console-ssh-type-error` --- ### 📝 Commits (3) - [`95092f8`](https://github.com/retspen/webvirtmgr/commit/95092f8b8974b0ca290e4935b09b38d8322861f3) Fixes a TypeError just before SSH connect - [`08af85b`](https://github.com/retspen/webvirtmgr/commit/08af85b65b39d2018af9c0d8275d05bbace45421) Adds reference to github PR #497 after creation - [`c63ff1a`](https://github.com/retspen/webvirtmgr/commit/c63ff1a863289c2405aef0f44eee1196bac484bf) CS: Properly break line to stay within line length ### 📊 Changes **1 file changed** (+7 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `console/webvirtmgr-console` (+7 -4) </details> ### 📄 Description Hi there, I just came across an error regarding the noVNC console. For security reasons, I only want VNC to listen on the loopback interface. In order to do so, I changed my connection type to SSH and set up authentication like described in the wiki. However, I was unable to connect to the VMs Console via Webvirtmgr. Skipping through the logs, I found the following exception: ``` WARNING:root:No local_settings file found. WebSocket server settings: - Listen on 127.0.0.1:6080 - Flash security policy server - SSL/TLS support - proxying from 127.0.0.1:6080 to ignore:ignore ... 4: 127.0.0.1: Plain non-SSL (ws://) WebSocket connection 4: 127.0.0.1: Version hybi-13, base64: 'False' 4: Fail to open tunnel : not all arguments converted during string formatting 4: handler exception: not all arguments converted during string formatting 5: 127.0.0.1: Plain non-SSL (ws://) WebSocket connection 5: 127.0.0.1: Version hybi-13, base64: 'False' 5: Fail to open tunnel : not all arguments converted during string formatting 5: handler exception: not all arguments converted during string formatting ^C 6: Got SIGINT, exiting In SystemExit ``` Strangely, `not all arguments converted during string formatting` is a TypeError occuring during sprintf-like functions. Digging into `console/webvirtmgr-console` I tracked the error back to the following block: ``` python self.msg("Try to open tunnel on %s@%s:%s on console %s:%s " + "(or socket %s)" % (connuser, connhost, connport, console_host, console_port, console_socket)) ``` Unfortunately, string substitution won't work here. Python substitutes the placeholders first, connects the string afterwards. As a result, a TypeError is thrown because six variables are supplied for a string with only one placeholder. I noticed you strictly use 80 chars per line at max, so my approach is to save the debug message into a variable `error_msg`, which will then be substituted with placeholders during the call to `self.msg`. Feel free to change this however you think would be a better style. These are probably the only three lines of Python I've written in the last five years :wink: Cheers, :beers: Alexander --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 16:40:06 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/webvirtmgr#673
No description provided.