omu / xokul

The Xokul Project
https://xokul.omu.sh
GNU General Public License v3.0
6 stars 0 forks source link

NoMethodError: undefined method `titleize_tr' for {:aciklama=>"Değiştirme", :kod=>"2"}:Hash #29

Closed huseyin closed 6 years ago

huseyin commented 6 years ago

View details in Rollbar: https://rollbar.com/htkaslan/xokul/items/9/



NoMethodError: undefined method `titleize_tr' for {:aciklama=>"Değiştirme", :kod=>"2"}:Hash
  File "/app/app/serializers/kps/queries/identities_serializer.rb", line 212, in block in <class:IdentitiesSerializer>
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model/serializer/field.rb", line 21, in instance_eval
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model/serializer/field.rb", line 21, in value
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model/serializer.rb", line 332, in block in attributes
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model/serializer.rb", line 329, in each
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model/serializer.rb", line 329, in each_with_object
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model/serializer.rb", line 329, in attributes
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model/serializer.rb", line 392, in attributes_hash
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model/serializer.rb", line 360, in serializable_hash
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model_serializers/adapter/attributes.rb", line 7, in serializable_hash
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model_serializers/adapter/base.rb", line 59, in as_json
  File "/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/json/encoding.rb", line 35, in encode
  File "/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/json/encoding.rb", line 22, in encode
  File "/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/core_ext/object/json.rb", line 41, in to_json
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model_serializers/serializable_resource.rb", line 8, in to_json
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model_serializers/logging.rb", line 69, in block (3 levels) in notify
  File "/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/callbacks.rb", line 109, in block in run_callbacks
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model_serializers/logging.rb", line 22, in block (3 levels) in instrument_rendering
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model_serializers/logging.rb", line 79, in block in notify_render
  File "/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/notifications.rb", line 168, in block in instrument
  File "/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/notifications/instrumenter.rb", line 23, in instrument
  File "/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/notifications.rb", line 168, in instrument
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model_serializers/logging.rb", line 78, in notify_render
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model_serializers/logging.rb", line 21, in block (2 levels) in instrument_rendering
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model_serializers/logging.rb", line 95, in block in tag_logger
  File "/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/tagged_logging.rb", line 71, in block in tagged
  File "/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/tagged_logging.rb", line 28, in tagged
  File "/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/tagged_logging.rb", line 71, in tagged
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model_serializers/logging.rb", line 95, in tag_logger
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model_serializers/logging.rb", line 20, in block in instrument_rendering
  File "/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/callbacks.rb", line 118, in instance_exec
  File "/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/callbacks.rb", line 118, in block in run_callbacks
  File "/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/callbacks.rb", line 136, in run_callbacks
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/active_model_serializers/logging.rb", line 68, in block (2 levels) in notify
  File "/app/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.1/lib/action_controller/metal/renderers.rb", line 157, in block in <module:Renderers>
  File "/app/vendor/bundle/ruby/2.5.0/gems/active_model_serializers-0.10.7/lib/action_controller/serialization.rb", line 62, in block (2 levels) in <module:Serialization>
  File "/app/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.1/lib/action_controller/metal/renderers.rb", line 150, in block in _render_to_body_with_renderer
  File "/app/vendor/ruby-2.5.1/lib/ruby/2.5.0/set.rb", line 338, in each_key
  File "/app/vendor/ruby-2.5.1/lib/ruby/2.5.0/set.rb", line 338, in each
  File "/app/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.1/lib/action_controller/metal/renderers.rb", line 146, in _render_to_body_with_renderer
  File "/app/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.1/lib/action_controller/metal/renderers.rb", line 142, in render_to_body
  File "/app/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.1/lib/abstract_controller/rendering.rb", line 25, in render
  File "/app/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.1/lib/action_controller/metal/rendering.rb", line 36, in render
  File "/app/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.1/lib/action_controller/metal/instrumentation.rb", line 46, in block (2 levels) in render
  File "/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/core_ext/benchmark.rb", line 14, in block in ms
  File "/app/vendor/ruby-2.5.1/lib/ruby/2.5.0/benchmark.rb", line 308, in realtime
  File "/app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/core_ext/benchmark.rb", line 14, in ms
  File "/app/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.1/lib/action_controller/metal/instrumentation.rb", line 46, in block in render
  File "/app/vendor/bundle/ruby/2.5.0/gems/actionpack-5.2.1/lib/action_controller/metal/instrumentation.rb", line 87, in cleanup_view_runtime
  File "/app/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.1/lib/active_record/railties/controller_runtime.rb", line 36, in cleanup_view_runtime
  File "/app/vendor/bundle/ruby/2.5.0/gems/a
msdundar commented 6 years ago

Kendi T.C. numaramı sorguladığımda (identities) bu hata geldi.

huseyin commented 6 years ago

@msdundar Bu, başlarda çok sık gelmesini beklediğim hatalardan. Serialize ederken birçok parametre nil geliyor. Muhtemelen bu parametre test tc'lerde nil dönüyordu veya boş string dönüyordu ve ben titleize ettim. Sende ise hash dönmüş. Düzeltirim bunu.

roktas commented 6 years ago

Anladığım kadarıyla (ilgili satır: https://github.com/omu/xokul/blob/dev/app/serializers/kps/queries/identities_serializer.rb#L212) basvuru_neden genel olarak String ama bu örnekte Hash? Bu durumda temel bir varsayım (String olması) gerçekleşmemiş oluyor. Hash olması halinde stringify mı yapacaksın? Yapacaksan nasıl? Örneğin {:aciklama=>"Değiştirme", :kod=>"2"} karşılığı ne olacak?

roktas commented 6 years ago

Bu arada bu KPS API'yi kim tasarlamışsa #$!££**??!

huseyin commented 6 years ago

@roktas hocam bu tip noktalarda kod benim için kriter. Eğer string ise hash yapıp kodu nil olarak ayarlıyorum. Buna bağlı bir sorgu yapılırsa bu kabul daha makul geliyor bana. String çok baz alınacak bir veri tipi değil bence

huseyin commented 6 years ago

Yani benim de hem hash hem string döndürmemin bir anlamı yok. Bunu KPS'de yapıyor zaten. Bir farkımız kalmıyor. Ya hep string döndüreceğim, ya da hep hash. Ama bunun Hash geldiğini ilk defa gördüm :) Uç durumları kullanmadan göremeyeceğiz gibi

msdundar commented 6 years ago

@huseyin Benim T.C. numarası mı uç durum olm :)

Şakası bir yana istersen 3-5bin kişi sorgulatayım gelen hatalara bakalım? Nasıl olsa rollbar'a düşecek?

huseyin commented 6 years ago

@msdundar abi şimdi sağlıklı baktım. kodla oynadım biraz. sen yeni kimlik almışsın. hata oradan gelmiş. Nokul'dan aldığım test T.C. lerde bir kişi hariç yeni kimlikli değiller. O kişide de bu parametre null geliyor. Sanırım benim gözümden kaçmış titleize etmişim.

Önerin gayet yerinde bence de yapalım :+1:

roktas commented 6 years ago

@huseyin işaret ettiğim satıra göre titleize ettiğinden string veya nil kabulü yapmışsın, bu kabulü nasıl değiştireceksin diye soruyorum? örneğin hash

msdundar commented 6 years ago

Yeni çipli kimlikten aldım :+1:

huseyin commented 6 years ago

Hocam hash ise hata yakalandığında onu kodda değiştireceğim. Bu kabullerin hepsi KPS sorgu sonuçlarına göre. Aslında bu satırda bir yanlışlık yok. O parametre hash olmalı. Şimdi hash'e göre değiştireceğim. Eğer hash olduğunda bu sefer hash'mi, nil'mi kabulü olacak. Hash ise standard şunu yap diyemiyorum. Çünkü response'daki hash'ler standart değil :(