Skip to content

Conversation

@johnmccrae
Copy link
Contributor

@johnmccrae johnmccrae commented Nov 4, 2025

Description

Acitvesupport is being a nightmare to manage. It has been removed from Chef Zero and Chef 19. We are trying to get rid of it across the board. In removing it from oc-chef-pedant we also noted a dependency on the chef-18 chef client. It was added solely to extract the chef version number. Why? That brought in an incredible amount of overhead and dependencies that we had no need for. This PR updates the KNIFE_VERSION constant to a known shipping chef-client version. The code had previously hard-coded a chef version in the gemfile so we just moved that version over to the request.rb file. Removing activesupport also had an effect on various other files since the code was actively using that gem. This was going to create a huge problem in chef-19, and chef-zero since they do NOT use activesupport. We updated things to replace the features that activesupport was providing. Finally, we also added a spec_helper and a readme so that users could test various spec files locally. Normally, you'd need a whole chef-server to run spec tests against but with the spec_helper you can bypass that for some of the tests. Anything that makes an HTTP request is going to fail but this helps.

Issues Resolved

  • Remove the dependency on Activesupport
  • Remove the dependency on Chef-18

Check List

@johnmccrae johnmccrae requested review from a team as code owners November 4, 2025 15:51
@netlify
Copy link

netlify bot commented Nov 4, 2025

👷 Deploy Preview for chef-server processing.

Name Link
🔨 Latest commit 7180875
🔍 Latest deploy log https://app.netlify.com/projects/chef-server/deploys/691b26981ab1ef000814e6e4

@jashaik
Copy link
Contributor

jashaik commented Nov 5, 2025

johnmccrae and others added 15 commits November 6, 2025 13:50
Signed-off-by: John McCrae <[email protected]>
Signed-off-by: Rishi Kumar Chawda <[email protected]>
Signed-off-by: Rishi Kumar Chawda <[email protected]>
Signed-off-by: Rishi Kumar Chawda <[email protected]>
Signed-off-by: Rishi Kumar Chawda <[email protected]>
Signed-off-by: Rishi Kumar Chawda <[email protected]>
Signed-off-by: Rishi Kumar Chawda <[email protected]>
Signed-off-by: Rishi Kumar Chawda <[email protected]>
johnmccrae and others added 4 commits November 7, 2025 21:33
…lockfile update for CI feedback

Signed-off-by: John McCrae <[email protected]>
- Convert group-scope api_url calls to util_api_url in search_spec.rb, word_break_spec.rb
- Update search_util.rb let blocks to use util_api_url in expected response bodies
- Prevents WrongScopeError when let blocks reference other lets during example group definition
- Affects: request_url lets, single/multiple_search_expected_results, fetch_search_index_success_response
- Fix search_should_return, search_result, should_not_find_any, do_paginated_search
- Replace api_url calls with Pedant::Config.pedant_platform.api_url directly
- These helper methods are called from within examples but don't have access to api_url let
Merge changes from PR #4119 by @rishichawda that converts helper methods
(api_url, unique_name, ensure_2xx, should_be_string, platform) to let blocks
returning lambdas/procs, requiring .call() at all call sites.

This approach was proven to reduce WrongScopeError failures from 2000+ to ~300
by making these helpers accessible from both example-group scope (let blocks,
macros) and example scope (it blocks, before(:each)).

Changes:
- Convert api_url, unique_name, ensure_2xx, should_be_string to let(:name) { ->(args) { ... } }
- Update all 740+ call sites to use .call() syntax
- Remove util_api_url class methods (now redundant)
- 68 files changed following PR #4119 pattern

Co-authored-by: Rishi Chawda <rishichawda@github>
Signed-off-by: John McCrae <[email protected]>
These helper methods were being called from let blocks, causing WrongScopeError.
Applied the same pattern as api_url: convert to let blocks returning lambdas,
update all call sites to use .call() syntax.

Changes:
- instance_eval_if_proc: 8 call sites updated
- impersonate: 2 call sites updated

Signed-off-by: John McCrae <[email protected]>
This was missed in the initial PR #4119 merge. should_be_string was converted
but should_be_hash was not, causing WrongScopeError when called from instance
methods like create_data_bag, create_data_bag_item, update_object, etc.

Changes:
- Convert should_be_hash to let(:should_be_hash) { ->(data) { ... } }
- Update 6 call sites to use .call() syntax

Signed-off-by: John McCrae <[email protected]>
The server method was still defined as 'def server' when platform was already
a let block, causing WrongScopeError when server was used in let blocks for
string interpolation like: let(:url) { \

Signed-off-by: John McCrae <[email protected]>
…st, update_object, internal_api_url) and update call sites; add unit spec validating behavior

Signed-off-by: John McCrae <[email protected]>
… platform.api_url in role add/delete to avoid before(:context) WrongScopeError

Signed-off-by: John McCrae <[email protected]>
…ers for before(:all) compatibility; fix impersonate call site

Signed-off-by: John McCrae <[email protected]>
…_platform.server_api_version in cookbook_util for before(:all) compatibility

Signed-off-by: John McCrae <[email protected]>
…kbook/delete_cookbook for before/after(:all) hook compatibility

Signed-off-by: John McCrae <[email protected]>
rishichawda and others added 7 commits November 12, 2025 18:38
Signed-off-by: Rishi Kumar Chawda <[email protected]>
we don't need this here

Signed-off-by: Rishi Kumar Chawda <[email protected]>
activesupport concern implementation https://github.com/rails/rails/blob/v7.2.3/activesupport/lib/active_support/concern.rb calls class_eval and not instance_exec. also updated the included method to match activesupport impl so that if base is not nil, it will always call super. this fixes the rspec error that made it return exit 1 even if there were no actual failures.

Signed-off-by: Rishi Kumar Chawda <[email protected]>
Remove chef gem form Gemfile, update comments, fix spec

Signed-off-by: neha-p6 <[email protected]>
…omnibus also pulls in license_scout as its direct dependency, bundle update license_scout gets blocked. Bump omnibus to pull in latest license_scout

Signed-off-by: neha-p6 <[email protected]>

Lazy load evalution to avoid Nomethod Error

Signed-off-by: neha-p6 <[email protected]>
Signed-off-by: neha-p6 <[email protected]>
@sonarqubecloud
Copy link

@sonarqube-for-infrastructure-prod

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

@neha-p6
Copy link
Collaborator

neha-p6 commented Nov 17, 2025

@neha-p6 neha-p6 marked this pull request as draft November 18, 2025 15:18
@neha-p6
Copy link
Collaborator

neha-p6 commented Nov 18, 2025

Closing in favor of #4122

@neha-p6 neha-p6 closed this Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants