Require ruby-openai in engine entry point (COPLAN-24 hotfix)#124
Merged
Conversation
The engine's gemspec declares ruby-openai as a runtime dependency,
but engine/lib/coplan.rb never required it — so the OpenAI constant
isn't defined for gem consumers that don't separately list it in
their own Gemfile.
The local worktree test suite happened to pass because the host
Gemfile here also lists `gem "ruby-openai"`, masking the missing
require. Downstream hosts (coplan-square) consuming only coplan-engine
hit:
NameError: uninitialized constant CoPlan::AiProviders::OpenAi::OpenAI
...in app/services/coplan/ai_providers/open_ai.rb:15
`client = OpenAI::Client.new(...)`
Add `require "openai"` alongside the existing `require "commonmarker"`
/ `require "diffy"` so the engine self-loads its declared deps.
Amp-Thread-ID: https://ampcode.com/threads/T-019e84ca-1d09-777c-baf1-b1f380ec013c
Co-authored-by: Amp <amp@ampcode.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hotfix for COPLAN-24.
What broke
Downstream hosts that consume
coplan-engineas a gem (e.g. coplan-square) hit:The engine's coplan.gemspec declares
ruby-openaias a runtime dep, but engine/lib/coplan.rb neverrequired it. The local test suite passed because the host Gemfile in this repo also listsgem "ruby-openai", which masked the missing require.Fix
Add
require "openai"to the engine entry point alongside the existingrequire "commonmarker"andrequire "diffy", so the engine self-loads its declared dependencies.Follow-up
Should add a smoke test that boots the engine in isolation (without the host Gemfile) to catch this class of bug — tracking separately.
🤖 Drafted with Amp.
Co-authored-by: Amp amp@ampcode.com