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

string assigned to variable leads to: Get Contents of URL failed because Shortcuts couldn't convert from Rich text to URL. #29

Open
chrysaora-achlyos opened this issue Jul 28, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@chrysaora-achlyos
Copy link

Describe the bug

string assigned to variable leads to: Get Contents of URL failed because Shortcuts couldn't convert from Rich text to URL.

Assignment of url to cmsURL, then used in downloadURL(url: cmsURL,... generates a "Get Contents of URL failed because Shortcuts couldn't convert from Rich text to URL." error

Import Shortcuts
//
dictionary() >> header
setValue(key: Content-Type, value: "application/json; charset=UTF-8", dictionary: header) >> header
//
var cmsURL = "https://jsonplaceholder.typicode.com/posts"
//
dictionary() >> reqDict
setValue(key:title, value: "My First Post", dictionary: reqDict) >> reqDict
setValue(key:body, value: "0.9", dictionary: reqDict) >> reqDict
setValue(key:userId, value:1, dictionary: reqDict) >> reqDict
//
downloadURL(
url: cmsURL,
method: POST,
headers: header,
requestType: Json,
requestJSON: reqDict,
requestVar: response) >> response
//
quicklook(input: response)

Working code with direct use of string:

import Shortcuts
//
dictionary() >> header
setValue(key: Content-Type, value: "application/json; charset=UTF-8", dictionary: header) >> header
//
dictionary() >> reqDict
setValue(key:title, value: "My First Post", dictionary: reqDict) >> reqDict
setValue(key:body, value: "0.9", dictionary: reqDict) >> reqDict
setValue(key:userId, value:1, dictionary: reqDict) >> reqDict
//
downloadURL(
url: "https://jsonplaceholder.typicode.com/posts",
method: POST,
headers: header,
requestType: Json,
requestJSON: reqDict,
requestVar: response) >> response
//
quicklook(input: response)

To Reproduce

Steps to reproduce the behavior:

  • paste the code above into a.jelly
  • run the command jelly a.jelly --export --out u_a.shortcut
  • run the command shortcuts sign --mode anyone --input u_a.shortcut --output a.shortcut
  • run the command open -a Shortcuts a.shortcut
  • click the "Add Shortcut" button
  • click to select the a Shortcut in Shortcuts
  • click to open the selected shortcut
  • run the shortcut with play icon on top right of shortcut
  • observe "Get Contents of URL failed because Shortcuts couldn't convert from Rich text to URL." error message

Expected behavior

Should preform the same as the second code snippet which runs without error

Screenshots

If applicable, add screenshots to help explain your problem.

Information

  • Device: [macBook Pro, 14-inch, 2021]
  • OS: [Sonoma 14.5]
  • Jellycuts Version [??? jelly command does not provide version info (/opt/homebrew/bin/jelly)]
  • Jailbroken? [No]

Additional context

Add any other context about the problem here.

@chrysaora-achlyos chrysaora-achlyos added the bug Something isn't working label Jul 28, 2024
@chrysaora-achlyos
Copy link
Author

  1. differt treatment of WFURL
  • Open-Jellycore WFURL is <string>cmsURL</string> , simply the name of variable
  • AppStore Jellycuts looks to be a dictionary with a Value key forced "${cmsURL}" string interpolation before transcribed to plist,
    and a key WFSerializationType
                <key>WFURL</key>
                <dict>
                        <key>Value</key>
                        <dict>
                                <key>attachmentsByRange</key>
                                <dict>
                                        <key>{0, 1}</key>
                                        <dict>
                                                <key>Aggrandizements</key>
                                                <array/>
                                                <key>Type</key>
                                                <string>Variable</string>
                                                <key>VariableName</key>
                                                <string>cmsURL</string>
                                        </dict>
                                </dict>
                                <key>string</key>
                                <string>&#xFFFC;</string>
                        </dict>
                        <key>WFSerializationType</key>
                        <string>WFTextTokenString</string>
                </dict>
  1. AppStore Jellycuts and Open-Jellycore have a few different WFWorkflowActionParameters

AppStore Jellycuts structure of is.workflow.actions.downloadurl

<dict>
        <key>WFWorkflowActionIdentifier</key>
        <string>is.workflow.actions.downloadurl</string>
        <key>WFWorkflowActionParameters</key>
        <dict>
                <key>CustomOutputName</key>          // common
                <key>UUID</key>                      // common
                <key>WFJSONValues</key>              // common
                <key>WFHTTPHeaders</key>             // common
                <key>WFRequestVariable</key>         // common
                <key>WFURL</key>                     // common

                <key>WFHTTPBodyType</key>
                <key>WFHTTPMethod</key>
        </dict>
</dict>

Open-Jellycore structure of is.workflow.actions.downloadurl

<dict>
        <key>WFWorkflowActionIdentifier</key>
        <string>is.workflow.actions.downloadurl</string>
        <key>WFWorkflowActionParameters</key>
        <dict>
                <key>CustomOutputName</key>          // common
                <key>UUID</key>                      // common
                <key>WFJSONValues</key>              // common
                <key>WFHTTPHeaders</key>             // common
                <key>WFRequestVariable</key>         // common
                <key>WFURL</key>                     // common

                <key>method</key>
                <key>requestType</key>
        </dict>
</dict>

@chrysaora-achlyos
Copy link
Author

chrysaora-achlyos commented Sep 3, 2024

core of the problem seems to be "url: <#String (Allows Variables)#>" only dealing with the String path and ignoring the (Allows Variables) case

downloadURL(url: <#String (Allows Variables)#>, method: <#Enumeration (WFHTTPMethod)#>, headers: <#Dictionary#>, requestType: <#Enumeration (WFHTTPBodyType)#>, requestJSON: <#Dictionary#>, requestVar: <#Variable#>)

There are many actions in Documentation/Actions that allow PARAM: <#String (Allows Variables)#>
1 editURL(
2 createURL(
3 writeText(
4 randomText
5 sendFeedback(
6 randomDateTime(
7 filterList(
8 dateToUnixTime(
9 removeEmoji(
10 removeNonPrintableCharacters(
11 trimWhitespace(
12 getEmojis(
13 removeEmptyLines(
14 removeDuplicateLines(
15 getTitleOfURL(
16 transformTextWithJavaScript(
17 formatDateDifference(
18 transformText(
19 setFileCreationModificationDate(
need to check for similar error with each, and find existing solution or fix in consistent method across them as a group

Also, need to find others in

  • Documentation/DataJar
  • Documentation/Drafts
  • Documentation/FocusedWork
  • Documentation/GizmoPack
  • Documentation/Progress
  • Documentation/Scriptable
  • Documentation/Shortcuts
  • Documentation/ToolboxPro
  • Documentation/WidgetPack
  • Documentation/aShell

@chrysaora-achlyos
Copy link
Author

chrysaora-achlyos commented Sep 4, 2024

I verified that on all the 'import Action' functions that take one variable of tyep <#String (Allows Variables)#>

  • 8.1 dateToUnixTime(
  • 9.1 removeEmoji(
  • 10.1 removeNonPrintableCharacters(
  • 11.1 trimWhitespace(
  • 12.1 getEmojis(
  • 13.1 removeEmptyLines(
  • 15.1 getTitleOfURL(

They all have the same issue, of using the variable name as a string instead of variable reference.

So this issue appears to be present any function that takes a parameter of type <#String (Allows Variables)#>. While this may mean it affect over a 100 such functions, it likely that a single solution might fix all for them.

@chrysaora-achlyos
Copy link
Author

see two commit for possible fix
chrysaora-achlyos@68c0f68
chrysaora-achlyos@5c25c05

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant