Coder Social home page Coder Social logo

Searching is Broken about chef-zero HOT 17 CLOSED

chef avatar chef commented on July 27, 2024
Searching is Broken

from chef-zero.

Comments (17)

jkeiser avatar jkeiser commented on July 27, 2024

Hmm, I haven't got a repro here. I have hashie-2.0.5 too. Can you try this quick to rule out an environment difference?

  1. git clone chef-zero && cd playground
  2. chef-zero -p 4000
  3. knife upload nodes
  4. knife search node name:blah

Expected results: 1 items found

Can you tell me what happens if you do this? (3+4 are from the same directory)

I tried the procedure with a downloaded node too, with no issue, but this will at least confirm that it's the node itself that is triggering the bug. If that's the case, it will help me a lot if you can send me a (possibly sanitized version of) the node json. Thanks!

from chef-zero.

andrewgross avatar andrewgross commented on July 27, 2024

Will do, was poking around Chef-Pedant and my issue should be covered, I'll dig in to see if I can find where it is wrong.

from chef-zero.

jkeiser avatar jkeiser commented on July 27, 2024

p.s. you need the latest knife-essentials for the above to work:

gem uninstall -a knife-essentials; gem install knife-essentials

from chef-zero.

andrewgross avatar andrewgross commented on July 27, 2024

Using Knife (or cURL) seems to work properly with the steps you gave. I will play around a bit more with Ridley and my data to see if I can pin it down.

from chef-zero.

andrewgross avatar andrewgross commented on July 27, 2024

Definitely something related to the data being put in place, but somehow just for search.

I uploaded my custom node info to the same server I had already verified was working.

Works with a proper response:

/search
/nodes
/nodes/my_custom_node

Fails:

/search/node

I will see if I can upload the data using knife instead of ridley to different effect, otherwise ill start diving in to the node data itself to see if I can pinpoint the issue.

from chef-zero.

andrewgross avatar andrewgross commented on July 27, 2024

Just ruled out ridley, going to dissect node data.

from chef-zero.

jkeiser avatar jkeiser commented on July 27, 2024

Thanks! I will also be happy to help debug if you can send me node data (though I'm in and out tonight). The node data I've uploaded doesn't do it.

It's entirely possible for something about your node data to be special. Given the error you're getting, I'm wondering if your data contains a data type that isn't in usual files. Maybe a number? A null? A boolean?

from chef-zero.

jkeiser avatar jkeiser commented on July 27, 2024

I just tried those and it didn't work. BTW, looking at the code this has something to do with a "normal" attribute (an attribute under the "normal" key). Possibly one that conflicts with a "default" attribute, but I'm guessing not. If you get rid of all automatic and override attributes from the node file, this should still repro. Then maybe try getting rid of default attributes from the node file, and see if it still repros.

Or send it to me and I'll happily slice and dice. I can understand not wanting to if there is sensitive data though!

Thanks tons for filing a bug, hopefully we can smash through this so you can continue with life :)

from chef-zero.

andrewgross avatar andrewgross commented on July 27, 2024

It works if I strip out the "normal" section of the node info. Here is the normal and default data (sanitized, but it still fails even after sanitization).

Normal Data: https://gist.github.com/andrewgross/aeaf3d0ef138b2565a40
Default Data: https://gist.github.com/andrewgross/9ae5104d6a6f8cd1d419

from chef-zero.

jkeiser avatar jkeiser commented on July 27, 2024

Yep, it only fails if you have BOTH the default and normal. Something is weird in the deep merge. Minimizing.

from chef-zero.

jkeiser avatar jkeiser commented on July 27, 2024

Here's the minimal repro:

{
"chef_type": "node",
"json_class": "Chef::Node",
"name": "blah",
"chef_environment": "_default",
"run_list": [],
"default": {
"expected_nodes": 1
},
"normal": {
"expected_nodes": 1
}
}

from chef-zero.

jkeiser avatar jkeiser commented on July 27, 2024

Appears to be a bug in Hashie. I can repro with this:

require 'hashie'

class Hash
include Hashie::Extensions::DeepMerge
end

{ x: 1 }.deep_merge({ x: 1})

from chef-zero.

andrewgross avatar andrewgross commented on July 27, 2024

Nice. Here is 'why'

http://stackoverflow.com/questions/13962147/why-cant-singleton-methods-be-defined-on-symbols-or-fixnums

In Hashie they are dumping the Hashie Deep Merge class in to the Hash that is passed in:

https://github.com/intridea/hashie/blob/master/lib/hashie/extensions/deep_merge.rb

However, it look's like the logic is failing and trying to dump this in to a Fixnum when they use the notation

(class << (tv = self[k]); self; end).send :include, Hashie::Extensions::DeepMerge

from chef-zero.

jkeiser avatar jkeiser commented on July 27, 2024

Yep. I've filed a bug against Hashie (hashie/hashie#99), but I've just copied Chef's deep_merge into chef-zero and will check in a fix shortly. Thanks tons :)

from chef-zero.

andrewgross avatar andrewgross commented on July 27, 2024

Awesome, thanks!

from chef-zero.

jkeiser avatar jkeiser commented on July 27, 2024

Version 1.2.1 released with fix. Let me know if it resolves!

from chef-zero.

andrewgross avatar andrewgross commented on July 27, 2024

Works like a charm, thanks @jkeiser

from chef-zero.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.