meteor/meteor · error · Error
A "url" property or function must be specified
Error message
A "url" property or function must be specified
What it means
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.
Source
Thrown at packages/deprecated/backbone/backbone.js:1436
// Correctly set child's `prototype.constructor`.
child.prototype.constructor = child;
// Set a convenience property in case the parent's prototype is needed later.
child.__super__ = parent.prototype;
return child;
};
// Helper function to get a value from a Backbone object as a property
// or as a function.
var getValue = function(object, prop) {
if (!(object && object[prop])) return null;
return _.isFunction(object[prop]) ? object[prop]() : object[prop];
};
// Throw an error when a URL is needed, and none is supplied.
var urlError = function() {
throw new Error('A "url" property or function must be specified');
};
}).call(this);
View on GitHub (pinned to 5076d2f818)
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.
Example fix
// before
const Item = Backbone.Model.extend({});
const item = new Item({ name: 'x' });
item.save(); // throws: no url
// after
const Item = Backbone.Model.extend({ urlRoot: '/api/items' });
const item = new Item({ name: 'x' });
item.save(); Defensive patterns
Strategy: validation
Validate before calling
function ensureUrl(modelOrCollection) {
const hasUrl = Boolean(
modelOrCollection.url ||
(modelOrCollection.collection && modelOrCollection.collection.url) ||
modelOrCollection.urlRoot
);
if (!hasUrl) throw new Error('Model/Collection needs a url or urlRoot before sync');
} Type guard
function hasUrl(target) {
return Boolean(target.url || target.urlRoot || (target.collection && target.collection.url));
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Defining a model class without urlRoot; instantiating a model outside any collection and calling save; forgetting to set url on a collection subclass.
Related errors
- Can't add an invalid model to a collection
- Cannot sort a set without a comparator
- Backbone.history has already been started
- Backbone.History is client-only, can't start on the server
- Method "${events[key]}" does not exist
AI-assisted analysis of meteor/meteor@5076d2f818 (2026-08-13).
Data as JSON: /api/errors/52e68abd436618d8.
Report an issue: GitHub.