Skip to content

"createTopic" returns a Topic with no ProjectId #1676

@julienperrault

Description

@julienperrault

Environment details

  • OS: Mac OS 13.1
  • Node.js version: 18.13.0
  • npm version: 8.19.3
  • @google-cloud/pubsub version: 3.2.1

Steps to reproduce

  1. Use the createTopic function on a PubSub Client
  2. The returned value (CreateTopicResponse) contain the created Topic but the topic.name value don't have the {{projectId}} rendered.

Exemple :

  • I use in local env. the PubSub Emulator (exposed at localhost:8085)
  • {{projectId}} = julienperrault
import {
  PubSub,
} from '@google-cloud/pubsub'

const client = new PubSub()

const main = async () => {
  const topicName = "test-topic"

  const createdTopic = await client
    .createTopic(topicName)
    .then(([topic]) => topic)
    .catch(err => {
      if (err.code === 6) {
        return client.topic(topicName)
      }
      return err
    }
  )
  console.log(createdTopic.name)

  const foundTopic = await client.topic(topicName)

  console.log(foundTopic.name)
}

main()

Console :

  1. Compile (npx tsc)
  2. Run (npm run start launch PUBSUB_EMULATOR_HOST=${PUBSUB_EMULATOR_HOST:-localhost:8085} node index.js)
npm run start

> start
> PUBSUB_EMULATOR_HOST=${PUBSUB_EMULATOR_HOST:-localhost:8085} node index.js

projects/{{projectId}}/topics/test-topic
projects/julienperrault/topics/test-topic

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: pubsubIssues related to the googleapis/nodejs-pubsub API.priority: p2Moderately-important priority. Fix may not be included in next release.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