Jump to content

for privacy reasons, replace user in paths with ~ in the debugger


Recommended Posts

When troubleshooting a workflow it is common procedure to post the output of the debugger.

In its original form, the name of the user would be listed in the path and end up being posted in a public forum. I suggest using the tilde ~.

In the example below, I changed the user name to a ~

thank you for considering my request.

 

 

 

[09:08:30.408] AppID[Script Filter] Queuing argument '(null)'

[09:08:30.495] AppID[Script Filter] Script with argv '(null)' finished

[09:08:30.496] ERROR: AppID[Script Filter] Code 127:~/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/DBA22BEA-10A5-4B77-8C71-2956468F8264: line 1: node: command not found

Link to comment
Share on other sites

When debugging, accuracy is of the utmost importance. Anything that is done to change a message makes it harder to debug.

 

For example, let’s say you have a workflow where you pass the string ~/Desktop to a piece of code that does ls "${1}". That will not work, because the tilde will not expand. But you’d never know because in other situations the debugger would be lying to you. Furthermore, if you passed a fixed string with a wrong home path, now it could be replaced with a tilde and it wouldn’t work either but you’d never know.

 

The debugger output isn’t just for sharing, it’s for yourself as well. Computers are literal and you need them to tell you the truth so you understand what they’re interpreting and you can properly fix things.

 

If your username reveals too much of your name (first and last name, instead of just rob, for example), you can replace it with xxxxx or similar, but don’t replace it with a tilde. Even the above leads to a loss of accuracy, which makes it harder to find issues.

Link to comment
Share on other sites

4 hours ago, vitor said:

When debugging, accuracy is of the utmost importance. Anything that is done to change a message makes it harder to debug.

 

For example, let’s say you have a workflow where you pass the string ~/Desktop to a piece of code that does ls "${1}". That will not work, because the tilde will not expand. But you’d never know because in other situations the debugger would be lying to you. Furthermore, if you passed a fixed string with a wrong home path, now it could be replaced with a tilde and it wouldn’t work either but you’d never know.

 

The debugger output isn’t just for sharing, it’s for yourself as well. Computers are literal and you need them to tell you the truth so you understand what they’re interpreting and you can properly fix things.

 

If your username reveals too much of your name (first and last name, instead of just rob, for example), you can replace it with xxxxx or similar, but don’t replace it with a tilde. Even the above leads to a loss of accuracy, which makes it harder to find issues.


I ran into the tilde not expanding in a workflow yesterday. 
 

donyou know when it doesn’t work ?

Link to comment
Share on other sites

@Terminal Why it wasn’t expanded will depend entirely on the code in the workflow. Alfred itself will expand the tilde when it makes sense and it has enough information. For example, in a File Picker from Workflow Configuration Alfred knows it is expecting a path so it will expand the tilde even before your code sees it (i.e. the code will always get the full path). But if you used a Text Field, then a starting tilde would be interpreted literally, because otherwise it could mess up your text input.


Picking up the example I gave above, consider these three cases (you can try them in a terminal):

  • ls ~/Desktop
  • ls ~/"Desktop"
  • ls "~/Desktop"

The first two will work but the third one will fail. This is because it is the shell doing the tilde expansion. In other words, in the first two the tilde is converted to the proper user directory path before it is passed to ls. On the third example, because the tilde is inside the quotes it is passed literally to ls so it won’t work unless you have a folder literally named ~ and that one has another folder called Desktop inside. Which is possible but I definitely wouldn’t recommend.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...