{"record":{"id":"52e68abd436618d8","repo":"meteor/meteor","slug":"a-url-property-or-function-must-be-specified","errorCode":null,"errorMessage":"A \"url\" property or function must be specified","messagePattern":"A \"url\" property or function must be specified","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/deprecated/backbone/backbone.js","lineNumber":1436,"sourceCode":"    // Correctly set child's `prototype.constructor`.\n    child.prototype.constructor = child;\n\n    // Set a convenience property in case the parent's prototype is needed later.\n    child.__super__ = parent.prototype;\n\n    return child;\n  };\n\n  // Helper function to get a value from a Backbone object as a property\n  // or as a function.\n  var getValue = function(object, prop) {\n    if (!(object && object[prop])) return null;\n    return _.isFunction(object[prop]) ? object[prop]() : object[prop];\n  };\n\n  // Throw an error when a URL is needed, and none is supplied.\n  var urlError = function() {\n    throw new Error('A \"url\" property or function must be specified');\n  };\n\n}).call(this);\n","sourceCodeStart":1418,"sourceCodeEnd":1440,"githubUrl":"https://github.com/meteor/meteor/blob/5076d2f818d3cac01d0cf8312fa5b2332076a4fb/packages/deprecated/backbone/backbone.js#L1418-L1440","documentation":"Backbone's urlError() helper throws when a model or collection needs a URL to sync (save/fetch/destroy) but neither the instance nor its class defines a `url` property or `url` function, and no urlRoot/collection url was inferable. Backbone cannot perform a server sync without knowing the endpoint. Backbone is a vendored, deprecated Meteor package.","triggerScenarios":"model.save() on a model with no url and no collection with a url; collection.fetch() on a collection with no url property; calling sync methods before wiring the model to a collection that provides the url.","commonSituations":"Defining a model class without urlRoot; instantiating a model outside any collection and calling save; forgetting to set url on a collection subclass.","solutions":["Define urlRoot on the model class (e.g. urlRoot: '/api/items') or url on the collection class.","Attach the model to a collection that has a url before calling save/fetch.","Pass {url: '/api/items'} in the options of the specific sync call."],"exampleFix":"// before\nconst Item = Backbone.Model.extend({});\nconst item = new Item({ name: 'x' });\nitem.save(); // throws: no url\n\n// after\nconst Item = Backbone.Model.extend({ urlRoot: '/api/items' });\nconst item = new Item({ name: 'x' });\nitem.save();","handlingStrategy":"validation","validationCode":"function ensureUrl(modelOrCollection) {\n  const hasUrl = Boolean(\n    modelOrCollection.url ||\n    (modelOrCollection.collection && modelOrCollection.collection.url) ||\n    modelOrCollection.urlRoot\n  );\n  if (!hasUrl) throw new Error('Model/Collection needs a url or urlRoot before sync');\n}","typeGuard":"function hasUrl(target) {\n  return Boolean(target.url || target.urlRoot || (target.collection && target.collection.url));\n}","tryCatchPattern":null,"preventionTips":["Always define urlRoot on standalone models and url on collections.","Attach models to a url-providing collection before sync.","Add a unit test that fetches/saves a sample instance."],"tags":["backbone","deprecated","model","sync","url","rest"],"backgroundTag":null,"analyzedSha":"5076d2f818d3cac01d0cf8312fa5b2332076a4fb","analyzedAt":"2026-08-13T03:27:40.142Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}