Repository navigation
Pubsub: Invalid resource name given #3334
Description
Activity
- addedtype: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.api: pubsubIssues related to the Pub/Sub API.Issues related to the Pub/Sub API.priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.
on Jun 1, 2018 Hi @DylanMeeus Sorry I wasn't able to repro this issue.
Can you make sure in this case, yourtopicNameis created by:ProjectTopicName topicName = ProjectTopicName.of("testProject-2013370", "testResource");If that still does not help, can you try
publisher = Publisher.newBuilder("projects/testProject-2013370/topics/testResource").build();and see if that works?
I am getting the same issue. I think it's when I end up pulling.
Jun 05, 2018 3:13:25 PM com.google.cloud.pubsub.v1.StreamingSubscriberConnection$1 onFailure SEVERE: terminated streaming with exception com.google.api.gax.rpc.InvalidArgumentException: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Invalid resource name given (name=random). Refer to https://cloud.google.com/pubsub/overview#names for more information. at com.google.api.gax.rpc.ApiExceptionFactory.createException(ApiExceptionFactory.java:49) at com.google.cloud.pubsub.v1.StreamingSubscriberConnection$1.onFailure(StreamingSubscriberConnection.java:241) at com.google.common.util.concurrent.Futures$4.run(Futures.java:1123) at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:435) at com.google.common.util.concurrent.AbstractFuture.executeListener(AbstractFuture.java:900) at com.google.common.util.concurrent.AbstractFuture.complete(AbstractFuture.java:811) at com.google.common.util.concurrent.AbstractFuture.setException(AbstractFuture.java:675) at com.google.common.util.concurrent.SettableFuture.setException(SettableFuture.java:53) at com.google.cloud.pubsub.v1.StreamingSubscriberConnection$StreamingPullResponseObserver.onError(StreamingSubscriberConnection.java:178) at io.grpc.stub.ClientCalls$StreamObserverToCallListenerAdapter.onClose(ClientCalls.java:419) at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:41) at io.grpc.internal.CensusStatsModule$StatsClientInterceptor$1$1.onClose(CensusStatsModule.java:684) at io.grpc.ForwardingClientCallListener.onClose(ForwardingClientCallListener.java:41) at io.grpc.internal.CensusTracingModule$TracingClientInterceptor$1$1.onClose(CensusTracingModule.java:391) at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:475) at io.grpc.internal.ClientCallImpl.access$300(ClientCallImpl.java:63) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.close(ClientCallImpl.java:557) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.access$600(ClientCallImpl.java:478) at io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(ClientCallImpl.java:590) at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37) at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:123) at java.util.concurrent.Executors$RunnableAdapter.call$$$capture(Executors.java:511) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java) at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266) at java.util.concurrent.FutureTask.run(FutureTask.java) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:748) Caused by: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Invalid resource name given (name=random). Refer to https://cloud.google.com/pubsub/overview#names for more information. at io.grpc.Status.asRuntimeException(Status.java:526) ... 21 moreTopicAdminClient.create().createTopic(topicName)topicName is Test
ProjectTopicName.of(ServiceOptions.getDefaultProjectId(), topic)again, topic is Test
SubscriptionAdminClient.create().createSubscription(name, topicName, PushConfig.getDefaultInstance(), 0)name is apparently randomIt kinda sorta seems to imply that random is just an invalid format for a subscriber name, however, if names have to be in a particular format it would be nice if the documentation specified this... The link provided in the exception mentions NOTHING about subscription name formatting.
@hzyi-google I will test this asap.
@MrThreepwood Names do have to adhere to a certain format. As you have no doubt experienced as well, the URL the exception refers you to is useless. (for which I have made #3333 , which was swiftly resolved so props for that!)The URL you should be looking at, as it turns out, is this one: https://cloud.google.com/pubsub/docs/admin#resource_names
Neither "random" nor "testResource" violate these restrictions.
I figured out what my actual issue was. I was accidentally passing the string "random" to
Subscriber.newBuilder() rather than he ProjectSubscriptionName.I now have it up and working. So obviously the full name should end up being something along the lines of projectId/name. If using the builder with the string name parameter it's not obvious what the actual issue is by the error provided.
Thanks for the quick reply.
@hzyi-google
I have tried it with the second builder you suggested - which worked.After that, I have also found the problem with my original code.. rather than using the "topic name" I had used the "topic id" in this line:
publisher = Publisher.newBuilder(topicName).build();.🤦♂️
Thanks for the alternative method, that eventually led me to the solution!
Glad it helped.
When I try to follow the example code as given here:
(NOTE: I altered the hardcoded strings here to match the ones I need)
It raises an exception on:
ApiFutures.allAsList(messageIdFutures).get();Exception:
When I publish a message through the web console, it works as intended and my code (based on the example subscriber code) can read it out correctly.
My resource name matches with what I see in the console though:
Project info:
Java version: 1.8.0_131
Pubsub dependency: 'com.google.cloud:google-cloud-pubsub:1.31.0'