GithubHelp home page GithubHelp logo

Comments (15)

folknor avatar folknor commented on June 9, 2024 1

Yeah I have no clue, please help.

from ok.sh.

folknor avatar folknor commented on June 9, 2024 1

Here - just for reference - is formatted json from a different debug run than the above comment. The only difference is that the uploaded file name contains a underscore ("_") - "folk_testmod.zip", but in the above comment it's "folktestmod.zip":

{
	"url": "https://api.github.com/repos/stellaris-mods/testing/releases/7806517",
	"assets_url": "https://api.github.com/repos/stellaris-mods/testing/releases/7806517/assets",
	"upload_url": "https://uploads.github.com/repos/stellaris-mods/testing/releases/7806517/assets?name=folk_testmod.zip",
	"html_url": "https://github.com/stellaris-mods/testing/releases/tag/20170919-r2",
	"id": 7806517,
	"tag_name": "20170919-r2",
	"target_commitish": "master",
	"name": null,
	"draft": false,
	"author": {
		"login": "folknor",
		"id": 233791,
		"avatar_url": "https://avatars2.githubusercontent.com/u/233791?v=4",
		"gravatar_id": "",
		"url": "https://api.github.com/users/folknor",
		"html_url": "https://github.com/folknor",
		"followers_url": "https://api.github.com/users/folknor/followers",
		"following_url": "https://api.github.com/users/folknor/following{/other_user}",
		"gists_url": "https://api.github.com/users/folknor/gists{/gist_id}",
		"starred_url": "https://api.github.com/users/folknor/starred{/owner}{/repo}",
		"subscriptions_url": "https://api.github.com/users/folknor/subscriptions",
		"organizations_url": "https://api.github.com/users/folknor/orgs",
		"repos_url": "https://api.github.com/users/folknor/repos",
		"events_url": "https://api.github.com/users/folknor/events{/privacy}",
		"received_events_url": "https://api.github.com/users/folknor/received_events",
		"type": "User",
		"site_admin": false
	},
	"prerelease": false,
	"created_at": "2017-09-19T11:52:53Z",
	"published_at": "2017-09-19T11:53:03Z",
	"assets": [],
	"tarball_url": "https://api.github.com/repos/stellaris-mods/testing/tarball/20170919-r2",
	"zipball_url": "https://api.github.com/repos/stellaris-mods/testing/zipball/20170919-r2",
	"body": "* Updated readme.md with changes from steam.bbcode.\n* Steam.bbcode update."
}

from ok.sh.

whiteinge avatar whiteinge commented on June 9, 2024 1

Ok, I can reproduce it now. The response headers are getting output along with the JSON response body. Still digging into why only in this method and not elsewhere.

from ok.sh.

whiteinge avatar whiteinge commented on June 9, 2024 1

That's a lot more readable and sane in Lua than sh 😀. Cool idea to use the path string from the docs. Very much inline with GH's "URI templates" approach and I've wondered why that hasn't seemed to catch on elsewhere.
Thanks for the reply 👍.

from ok.sh.

folknor avatar folknor commented on June 9, 2024

Here's some output with set -x:

+ [ X-GitHub-Request-Id = Link_next ]
+ IFS=:  read -r hdr val
+ output=
+ printf %s\n 
+ cat
+ :
+ cat
+ [ 1 -eq 1 ]
+ _log info Remaining next link follows: 50
+ local level=info
+ local message=Remaining next link follows: 50
+ shift 2
+ local lname
+ lname=INFO
+ level=4
+ printf %s %s: %s\n ok.sh INFO Remaining next link follows: 50
ok.sh INFO: Remaining next link follows: 50
+ [ -n  ]
+ return
+ local upload_url={ "url": "https://api.github.com/repos/stellaris-mods/testing/releases/7806555", "assets_url": "https://api.github.com/repos/stellaris-mods/testing/releases/7806555/assets", "upload_url": "https://uploads.github.com/repos/stellaris-mods/testing/releases/7806555/assets?name=folktestmod.zip", "html_url": "https://github.com/stellaris-mods/testing/releases/tag/20170919-r3", "id": 7806555, "tag_name": "20170919-r3", "target_commitish": "master", "name": null, "draft": false, "author": { "login": "folknor", "id": 233791, "avatar_url": "https://avatars2.githubusercontent.com/u/233791?v=4", "gravatar_id": "", "url": "https://api.github.com/users/folknor", "html_url": "https://github.com/folknor", "followers_url": "https://api.github.com/users/folknor/followers", "following_url": "https://api.github.com/users/folknor/following{/other_user}", "gists_url": "https://api.github.com/users/folknor/gists{/gist_id}", "starred_url": "https://api.github.com/users/folknor/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/folknor/subscriptions", "organizations_url": "https://api.github.com/users/folknor/orgs", "repos_url": "https://api.github.com/users/folknor/repos", "events_url": "https://api.github.com/users/folknor/events{/privacy}", "received_events_url": "https://api.github.com/users/folknor/received_events", "type": "User", "site_admin": false }, "prerelease": false, "created_at": "2017-09-19T11:56:11Z", "published_at": "2017-09-19T11:56:36Z", "assets": [ ], "tarball_url": "https://api.github.com/repos/stellaris-mods/testing/tarball/20170919-r3", "zipball_url": "https://api.github.com/repos/stellaris-mods/testing/zipball/20170919-r3", "body": "* Testing without _ in name." }
/home/folk/.local/bin/ok.sh: 1566: local: "url":: bad variable name
+ excode=2
+ trap - EXIT
+ exec
+ exec
+ exec
+ rm -rf /tmp/ok.sh.3915.6785868917
+ exit 2

from ok.sh.

whiteinge avatar whiteinge commented on June 9, 2024

Thanks for all the details. I'll try to reproduce and report back.

from ok.sh.

folknor avatar folknor commented on June 9, 2024

I have a lot more debug output and I'm ready to assist in testing for the next 3-4 hours if needed.

from ok.sh.

whiteinge avatar whiteinge commented on June 9, 2024

Thanks for the offer! I won't be able to get to it until after work so several hours at the soonest but I'll comment when I do.

from ok.sh.

whiteinge avatar whiteinge commented on June 9, 2024

Does it work if you remove the -j flag?

This function is an outlier in that it's the only one that requires jq to perform an internal query. I've thought about removing it or splitting it out for that reason (see #9). That said, it at least needs a check in its current form. I've added one in #48.

from ok.sh.

folknor avatar folknor commented on June 9, 2024

No, it does not work without -j, I said that in the initial description.

I will try again with your latest commits soon, thank you.

from ok.sh.

folknor avatar folknor commented on June 9, 2024

Same error as before, here is all the output from -vvv -x, with raw binary data snipped out: https://hastebin.com/raw/apivosazig

from ok.sh.

folknor avatar folknor commented on June 9, 2024

That said, it does actually upload the asset. It just errors immediately after.

from ok.sh.

whiteinge avatar whiteinge commented on June 9, 2024

Thanks, I missed the test without the -j flag. Looks like the JSON response from the intermediary step is getting mangled somewhere. I'll take another stab at reproducing.

from ok.sh.

whiteinge avatar whiteinge commented on June 9, 2024

This function may just be too fragile so I'm thinking of stripping it down to just the basics (#65). A lot less convenient but hopefully more straightforward to use if edge-cases happen. Thoughts welcome.

from ok.sh.

folknor avatar folknor commented on June 9, 2024

Seems entirely sensible to me. I didn't want to bother you with this, and I'm much more comfortable with lua than bash scripting, so I wrote a replacement for myself a year or so ago.

The code is quite insane, because I had this "brilliant idea" that it should generate the functions from the github docs per path, for example to implement GET /repos/:owner/:repo/issues/:number/labels in my library, all you do is write get("repos/:owner/:repo/issues/:number/labels"), and you're done.

Optionally, you can write

get("repos/:owner/:repo/issues/:number/labels", {
    "state", "open", {
        open = true,
        closed = true,
        all = true,
    },
    ...
})

To denote that the runtime-generated API function should take an argument "state" that it passes as a HTTP parameter, where the default value is "open", and the 3 allowed values are open/closed/all.

To then call this function in your own code, you do

local _gh = require("lua-github")
local httpHeaders, jsonResponse = _gh.GET["repos/:owner/:repo/issues/:number/labels"](
    "folknor",
    "repository-name",
    42,
    "closed"
)
print(jsonResponse.upload_url) -- The response in this case has no .upload_url, I guess

The library worked when I made it, but I've not used it for a year or so. GH might have changed their API surface as well, for all I know.

I'm not sure why I described the code in such detail above, but it started by wanting to explain why I hadn't pestered you about my ok.sh upload_asset bug report :-)

https://github.com/folknor/lua-github/blob/master/src/github.lua

from ok.sh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.