{"record":{"id":"c05fde0d292e0795","repo":"meteor/meteor","slug":"you-must-provide-a-valid-topic-to-create-a-subscri","errorCode":null,"errorMessage":"You must provide a valid topic to create a subscription.","messagePattern":"You must provide a valid topic to create a subscription\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/deprecated/amplify/amplify.js","lineNumber":45,"sourceCode":"\n\t\tif ( !subscriptions[ topic ] ) {\n\t\t\treturn true;\n\t\t}\n\n\t\ttopicSubscriptions = subscriptions[ topic ].slice();\n\t\tfor ( length = topicSubscriptions.length; i < length; i++ ) {\n\t\t\tsubscription = topicSubscriptions[ i ];\n\t\t\tret = subscription.callback.apply( subscription.context, args );\n\t\t\tif ( ret === false ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\treturn ret !== false;\n\t},\n\n\tsubscribe: function( topic, context, callback, priority ) {\n\t\tif ( typeof topic !== \"string\" ) {\n\t\t\tthrow new Error( \"You must provide a valid topic to create a subscription.\" );\n\t\t}\n\n\t\tif ( arguments.length === 3 && typeof callback === \"number\" ) {\n\t\t\tpriority = callback;\n\t\t\tcallback = context;\n\t\t\tcontext = null;\n\t\t}\n\t\tif ( arguments.length === 2 ) {\n\t\t\tcallback = context;\n\t\t\tcontext = null;\n\t\t}\n\t\tpriority = priority || 10;\n\n\t\tvar topicIndex = 0,\n\t\t\ttopics = topic.split( /\\s/ ),\n\t\t\ttopicLength = topics.length,\n\t\t\tadded;\n\t\tfor ( ; topicIndex < topicLength; topicIndex++ ) {","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/meteor/meteor/blob/5076d2f818d3cac01d0cf8312fa5b2332076a4fb/packages/deprecated/amplify/amplify.js#L27-L63","documentation":"amplify.subscribe() requires its first argument (the topic) to be a string. The signature is (topic, context, callback, priority) with flexible argument handling, but the topic gate is strict. A non-string topic throws before the subscription is registered. amplify is a deprecated vendored library.","triggerScenarios":"amplify.subscribe(null, cb); amplify.subscribe(someNumber, ctx, fn); a topic variable that failed to resolve to a string.","commonSituations":"Subscribing with a dynamic topic from config/user input that is not validated; refactor that introduced an undefined topic; legacy code still on amplify.","solutions":["Validate/coerce the topic to a string before subscribing.","Consider replacing amplify subscriptions with Tracker/ReactiveVar or a modern event emitter."],"exampleFix":"// before\namplify.subscribe(config.channel, ctx, handler); // config.channel undefined -> throws\n\n// after\nif (typeof config.channel === 'string') {\n  amplify.subscribe(config.channel, ctx, handler);\n}","handlingStrategy":"type-guard","validationCode":"function safeSubscribe(topic, context, callback, priority) {\n  if (typeof topic !== 'string' || !topic) {\n    throw new TypeError('amplify.subscribe requires a non-empty string topic');\n  }\n  return amplify.subscribe(topic, context, callback, priority);\n}","typeGuard":"function isTopic(v) { return typeof v === 'string' && v.length > 0; }","tryCatchPattern":null,"preventionTips":["Store topic strings in a constants module and reference them.","Migrate to Tracker or a modern emitter for new code."],"tags":["amplify","deprecated","pubsub","validation","client"],"backgroundTag":null,"analyzedSha":"5076d2f818d3cac01d0cf8312fa5b2332076a4fb","analyzedAt":"2026-08-13T03:27:40.142Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}