-
Notifications
You must be signed in to change notification settings - Fork 451
Setting mediaType doesn't work #243
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
Comments
If you're on the latest version of this action, we're using Octokit 3.5.1 |
I see, thanks for the response. I figured out what I misunderstood. I thought that setting the media type to Example: https://api.github.com/repos/actions/github-script/contents/README.md
you get a different json object although the requested url is the same. That's totally confusing and I haven't found anything about this in the octokit documentation. |
Ok I have to reopen this. I did the above test directly with node and not in the context of the GitHub script action. This morning I tested it again with this action and it doesn't work, although the mediaType is set. I still get the base64 encoded data as a response. I also noticed that the User-Agent is set to |
@joshmgross As you can see, the content is encoded as base64 although the mediaType format is set to raw. As I don't get this error when I run this with the latest octokit in node directly, I assume this must be a bug of this action. Can you have a look, please? |
I ran into the same issue and was able to work around it like this: - name: install npm packages
run: |
npm install @octokit/rest @actions/github
- uses: actions/github-script@v6
with:
script: |
const { Octokit } = require("@octokit/rest");
const { getOctokitOptions } = require('@actions/github/lib/utils');
const github2 = new Octokit(getOctokitOptions(process.env.GITHUB_TOKEN)); Of course this is suboptimal, but at least it behaves the same as when run directly via node locally, or from within custom JS actions. |
bug level is on march 3 not updating |
I've traced this down to how the action handles You can see this by running the following script: const endpoint = github.request.endpoint;
core.info(JSON.stringify(endpoint.DEFAULTS.mediaType));
core.info(endpoint({}).headers.accept);
core.info(endpoint({ mediaType: { format: 'diff' } }).headers.accept); This outputs:
Note the
The issue is this line: Line 43 in 98814c5
Inputs are read from environment variables and when the variable is missing or empty, the empty string is used. Splitting an empty string results in an array with a single empty string. The work-around is to pop that empty string off the defaults:
I'll create a PR to fix the input handling (it also affects setting the user agent, and the debug flag should really use |
What version of octokit is used in this action? I'm trying to get the contents of a file in a repository with:
but it doesn't work. I always get the default response as if mediaType isn't set. Maybe this is not yet supported in the octokit client used in this action?
I looked at the debug information of the request and the headers don't include an
Accept
header. I expect theAccept
header to be set toapplication/vnd.github.v3.raw+json
The text was updated successfully, but these errors were encountered: