GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — pubsub: unhelpful error message when trying to publish a string. · Issue #500 · googleapis/google-cloud-node

pubsub: unhelpful error message when trying to publish a string. #500

New issue
Copy link
New issue
Copy link
Closed
#501
Closed
pubsub: unhelpful error message when trying to publish a string.#500
#501
Copy link
Assignees
yoshi-automation
Labels
🚨This issue needs some love.api: pubsubIssues related to the Pub/Sub API.triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Description

@tmatsuo
tmatsuo
opened on Apr 14, 2015
Issue body actions

When I do the following:

topic.publish('New message!', function(err) }
}

I get:

buffer.js:188
        throw new TypeError('First argument needs to be a number, ' +
              ^
TypeError: First argument needs to be a number, array or string.
    at new Buffer (buffer.js:188:15)
    at Topic.formatMessage_ (/usr/local/google/home/tmatsuo/node_modules/gcloud/lib/pubsub/topic.js:80:20)
    at Array.map (native)
    at Topic.publish (/usr/local/google/home/tmatsuo/node_modules/gcloud/lib/pubsub/topic.js:183:24)
    at null._onTimeout (/usr/local/google/home/tmatsuo/tmp/mayran/mysubscribe.js:44:27)
    at Timer.listOnTimeout [as ontimeout] (timers.js:112:15)

Under the cover, the code is trying to make message.data (which is undefined) a buffer:

Topic.formatMessage_ = function(message) {
  if (!util.is(message.data, 'buffer')) {
    message.data = new Buffer(JSON.stringify(message.data));
  }

  message.data = message.data.toString('base64');

  return message;
};

Maybe type check first and give helpful error messages?

Activity

Next
  1. stephenplusplus
    added a commit that references this issue on Apr 14, 2015

    pubsub: type check input. fixes googleapis#500

    This issue will close once commit b6ba3e9 is merged into the 'master' branch.
    b6ba3e9
  2. stephenplusplus commented on Apr 14, 2015

    @stephenplusplus
    stephenplusplus
    on Apr 14, 2015
    Contributor
    More actions

    Good idea. PR sent!

  3. ryanseys
    closed this as completedin #501on Apr 15, 2015
  4. ryanseys
    added a commit that references this issue on Apr 15, 2015

    Merge pull request #501 from stephenplusplus/spp--pubsub-publish-erro…

    This issue will close once commit 64b6140 is merged into the 'main' branch.
    64b6140
  5. jgeewax
    added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    api: pubsubIssues related to the Pub/Sub API.
    on May 14, 2015
  6. yoshi-automation
    added
    triage meI really want to be triaged.
    🚨This issue needs some love.
    on Apr 6, 2020
  7. JustinBeckwith
    assigned
    yoshi-automation
    on Feb 1, 2021
  8. chingor13
    added 3 commits that reference this issue on Aug 22, 2022

    chore(nodejs): use cloud-rad publication process (#1112) (#500)

    e026887

    chore(nodejs): use cloud-rad publication process (#1112) (#500)

    5ea0d04

    chore(nodejs): use cloud-rad publication process (#1112) (#500)

    20f5ad8
  9. sofisl
    added 2 commits that reference this issue on Sep 15, 2022

    fix: Updating WORKSPACE files to use the newest version of the Typesc…

    b705624

    chore: release 2.2.5 (#501)

    9e7b84a
  10. sofisl
    added a commit that references this issue on Sep 27, 2022

    chore(deps): update dependency yargs to v16 (#500)

    782356b
  11. 12 remaining items

  12. GautamSharda
    added a commit that references this issue on Jan 15, 2026

    chore: add dev dependencies for cloud-rad ref docs (#500)

    950247f
  13. miguelvelezsa
    added a commit that references this issue on Jan 21, 2026

    chore: debrand Stackdriver Logging into Cloud Logging (#500)

    c08cd19
  14. sofisl
    added a commit that references this issue on Feb 4, 2026

    chore: debrand Stackdriver Logging into Cloud Logging (#500)

    5654d1f
  15. GautamSharda
    added a commit that references this issue on Feb 5, 2026

    chore: add dev dependencies for cloud-rad ref docs (#500)

    37f8c17
  16. GautamSharda
    added a commit that references this issue on Feb 23, 2026

    chore: add dev dependencies for cloud-rad ref docs (#500)

    52608fe
  17. sofisl
    added a commit that references this issue on Feb 25, 2026

    feat: release @google-cloud/storage v2.3.0 (#500)

    749c1be
  18. GautamSharda
    added a commit that references this issue on Feb 26, 2026

    chore: add dev dependencies for cloud-rad ref docs (#500)

    2e1c2a4
  19. sofisl
    added a commit that references this issue on Feb 26, 2026

    build: ignore googleapis.com in doc link check (#500)

    5cefd9d
  20. GautamSharda
    added 2 commits that reference this issue on Mar 5, 2026

    chore(deps): update dependency typescript to ~3.5.0 (#500)

    a810b85

    fix(docs): add jsdoc-region-tag plugin (#500)

    61740af
  21. thiyaguk09
    added a commit that references this issue on Mar 18, 2026

    feat: release @google-cloud/storage v2.3.0 (googleapis#500)

    55be96a
  22. GautamSharda
    added 2 commits that reference this issue on Mar 23, 2026

    feat: support apiEndpoint override (#500)

    ace27e4

    feat: support apiEndpoint override (#500)

    04c6490
  23. shivanee-p
    added a commit that references this issue on Mar 27, 2026

    feat: support apiEndpoint override (#500)

    79e1512
  24. thiyaguk09
    added a commit that references this issue on May 5, 2026

    feat: support apiEndpoint override (googleapis#500)

    8a4eca6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @yoshi-automation
    yoshi-automation

Labels

🚨This issue needs some love.api: pubsubIssues related to the Pub/Sub API.triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.