Shopify / tapioca

The swiss army knife of RBI generation
MIT License
746 stars 128 forks source link

v0.11.0 doesn't find some Rails models in Rails 6 #1416

Closed alex-tan closed 10 months ago

alex-tan commented 1 year ago

I tested to make sure that this was the version this bug was introduced in. Around 10% of our Rails models have their rbi file removed in this version when running tapioca dsl. I don't see any obvious reason why some models are removed and others aren't. Any ideas?

KaanOzkan commented 1 year ago

We're not seeing any removals on our monolith and there doesn't seem to be any significant changes introduced on to how DSL RBIs are generated. What are the contents of the RBI files that are removed? They may be legitimate due to changes in specific DSL compilers.

alex-tan commented 1 year ago

It's removing the entirety of files for some ActiveRecord models, some Sidekiq jobs.

Sample of ActiveRecord dsl content being removed:

class UppyFile
  include GeneratedAssociationMethods
  include GeneratedAttributeMethods
  extend CommonRelationMethods
  extend GeneratedRelationMethods

  private

  sig { returns(NilClass) }
  def to_ary; end

  module CommonRelationMethods
    sig { params(block: T.nilable(T.proc.params(record: ::UppyFile).returns(T.untyped))).returns(T::Boolean) }
    def any?(&block); end

    sig { params(column_name: T.any(String, Symbol)).returns(T.untyped) }
    def average(column_name); end

    sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: ::UppyFile).void)).returns(::UppyFile) }
    def build(attributes = nil, &block); end

    sig { params(operation: Symbol, column_name: T.any(String, Symbol)).returns(T.untyped) }
    def calculate(operation, column_name); end

    sig { params(column_name: T.untyped).returns(T.untyped) }
    def count(column_name = nil); end

    sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: ::UppyFile).void)).returns(::UppyFile) }
    def create(attributes = nil, &block); end

    sig { params(attributes: T.untyped, block: T.nilable(T.proc.params(object: ::UppyFile).void)).returns(::UppyFile) }
    def create!(attributes = nil, &block); end

A Sidekiq job being removed:

# typed: true

# DO NOT EDIT MANUALLY
# This is an autogenerated file for dynamic methods in `Util::DevS3Copier::CopyDocumentPageJob`.
# Please instead update this file by running `bin/tapioca dsl Util::DevS3Copier::CopyDocumentPageJob`.

class Util::DevS3Copier::CopyDocumentPageJob
  class << self
    sig { params(document_page_id: T.untyped).returns(String) }
    def perform_async(document_page_id); end

    sig { params(interval: T.any(DateTime, Time), document_page_id: T.untyped).returns(String) }
    def perform_at(interval, document_page_id); end

    sig { params(interval: Numeric, document_page_id: T.untyped).returns(String) }
    def perform_in(interval, document_page_id); end
  end
end
KaanOzkan commented 1 year ago

And just to confirm the application code or the database wasn't changed in between your tests on different tapioca versions? For example Util::DevS3Copier::CopyDocumentPageJob includes Sidekiq::Worker?

alex-tan commented 1 year ago

Correct, I tested the various versions on the same code.

dirceu commented 1 year ago

@alex-tan is your Rails app using Zeitwerk or the classic autoloader?

alex-tan commented 1 year ago

Looks like it's classic:

Rails.configuration.autoloader
=> :classic
paracycle commented 10 months ago

Is this still a problem you are experiencing @alex-tan? If so, could you send us a small reproduction please, so that we can see what's going wrong and fix it?

Until then, I will be assuming that this is not a problem anymore.

alex-tan commented 10 months ago

It may be an issue but closing the issue is ok with me as we've upgraded all our apps to Rails 7 👍🏼