dianping/cat · error · TypeError

Object.keys called on a non-object

Error message

Object.keys called on a non-object

What it means

Error "Object.keys called on a non-object" thrown in dianping/cat.

Source

Thrown at cat-home/src/main/webapp/assets/js/uncompressed/x-editable/bootstrap-editable.js:754

        getConfigData: function($element) {
            var data = {};
            $.each($element.data(), function(k, v) {
                if(typeof v !== 'object' || (v && typeof v === 'object' && (v.constructor === Object || v.constructor === Array))) {
                    data[k] = v;
                }
            });
            return data;
        },

        /*
         returns keys of object
        */
        objectKeys: function(o) {
            if (Object.keys) {
                return Object.keys(o);  
            } else {
                if (o !== Object(o)) {
                    throw new TypeError('Object.keys called on a non-object');
                }
                var k=[], p;
                for (p in o) {
                    if (Object.prototype.hasOwnProperty.call(o,p)) {
                        k.push(p);
                    }
                }
                return k;
            }

        },
        
       /**
        method to escape html.
       **/
       escape: function(str) {
           return $('<div>').text(str).html();
       },

View on GitHub (pinned to e815e74d4c)

Solutions

  1. Pass a plain object to the API that internally calls Object.keys; check for null or undefined options.
  2. Guard the call with a typeof check before invoking the editable plugin.

When it happens

Trigger: Triggered when Object.keys is invoked with a null, undefined, or primitive value inside bootstrap-editable option handling.

Common situations: See trigger scenarios.


AI-assisted analysis of dianping/cat@e815e74d4c (2026-08-14). Data as JSON: /api/errors/fa2c8ad327171b01. Report an issue: GitHub.