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

blogger v3 large blogids gets floored #1862

Closed
atlemagnussen opened this issue Oct 19, 2019 · 2 comments · Fixed by #1896
Closed

blogger v3 large blogids gets floored #1862

atlemagnussen opened this issue Oct 19, 2019 · 2 comments · Fixed by #1896
Assignees
Labels
type: docs Improvement to the documentation for an API.

Comments

@atlemagnussen
Copy link

atlemagnussen commented Oct 19, 2019

TLDR
blogId 7734453256887931626 becomes
blogId 7734453256887932000

when using this library, samme call with curl works fine

Environment details

  • OS: 5.3.7-arch1-1-ARCH
  • Node.js version: v10.16.3
  • npm version: 6.12.0
  • googleapis version: 44.0.0

Steps to reproduce

  1. Copy paste your simplest example of fetching info about a blog with a large number, ie mine is 7734453256887931626
const {google} = require('googleapis');
const blogger = google.blogger({
    version: 'v3',
    auth: 'XXX'
});
const main = async () => {
    const res = await blogger.blogs.get({blogId: 734453256887931626});
    console.log(`${res.data.name} has ${res.data.posts.totalItems} posts! The blog url is ${res.data.url}`);
};
main().catch(console.error);
  1. Inspect with VsCode or something, you will get 404 and you will find the url that is called, and the blogId is now 7734453256887932000
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Oct 20, 2019
@bcoe bcoe added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. external This issue is blocked on a bug with the actual product. and removed triage me I really want to be triaged. labels Oct 22, 2019
@bcoe
Copy link
Contributor

bcoe commented Oct 22, 2019

@atlemagnussen thanks for the bug report 👍

@JustinBeckwith JustinBeckwith added type: docs Improvement to the documentation for an API. and removed external This issue is blocked on a bug with the actual product. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Dec 3, 2019
@JustinBeckwith JustinBeckwith self-assigned this Dec 3, 2019
@JustinBeckwith
Copy link
Contributor

So I think I know what's happening. The type of blogId here should be a string. 734453256887931626 is too big to be represented by by a JavaScript integer!

image

The fix is to wrap the blogId in quotes to make it a string:

const {google} = require('googleapis');
const blogger = google.blogger({
    version: 'v3',
    auth: 'XXX'
});
const main = async () => {
    const res = await blogger.blogs.get({blogId: '734453256887931626'});
    console.log(`${res.data.name} has ${res.data.posts.totalItems} posts! The blog url is ${res.data.url}`);
};
main().catch(console.error);

There's a fix for the docs over in #1896 :)

@bcoe bcoe closed this as completed in #1896 Dec 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: docs Improvement to the documentation for an API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants