Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot create an API resource from admin if has_form is unchecked #1111

Closed
Ayon95 opened this issue Sep 15, 2022 · 2 comments
Closed

Cannot create an API resource from admin if has_form is unchecked #1111

Ayon95 opened this issue Sep 15, 2022 · 2 comments
Assignees
Labels
bug Something isn't working high priority

Comments

@Ayon95
Copy link
Contributor

Ayon95 commented Sep 15, 2022

Describe the bug
A 500 server error is raised when trying to create an API resource for an API namespace whose has_form property is set to false

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'API' and create an API namespace
  2. Make sure that "Has form" is unchecked
  3. Click on the button to create a new API resource

Expected behavior
A page to create a new API resource should appear instead of 500 server error

@donrestarone
Copy link
Contributor

donrestarone commented Jan 12, 2023

this bug is affecting sipshucksip.com

Screen Shot 2023-01-12 at 5 39 18 PM

@donrestarone donrestarone added high priority bug Something isn't working labels Jan 12, 2023
@sthajay sthajay self-assigned this Jan 12, 2023
@donrestarone
Copy link
Contributor

donrestarone commented Jan 13, 2023

Screen Shot 2023-01-12 at 8 42 02 PM

error from sipshucksip.com

An ActionView::Template::Error occurred in api_resources#new:

  undefined method `dig' for nil:NilClass
  app/helpers/api_forms_helper.rb:48:in `map_non_primitive_data_type'


-------------------------------
Request:
-------------------------------

  * URL        : https://public.sipshucksip.com/api_namespaces/4/resources/new
  * HTTP Method: GET
  * IP address : 27.34.22.234
  * Parameters : {"controller"=>"comfy/admin/api_resources", "action"=>"new", "api_namespace_id"=>"4"}
  * Timestamp  : 2023-01-12 16:53:53 UTC
  * Server : ip-172-31-41-187
    * Rails root : /var/www/violet/releases/20230111152108
  * Process: 4070979

-------------------------------
Session:
-------------------------------

  * session id: [FILTERED]
  * data: {"session_id"=>"a2772a98b625cddaff0a51261dab2b99",
   "user_return_to"=>"/api_namespaces/4/resources/new",
   "warden.user.user.key"=>[[10], "$2a$12$gUoPjYdnj.KuVW1ERT2fle"],
   "warden.user.user.session"=>{"last_request_at"=>1673542433},
   "site_id"=>1,
   "_csrf_token"=>"Y4gzMswxntcrJgH8C8UiAie-WkYnkN-xFxMdflTSeGE="}

-------------------------------
Environment:
-------------------------------

  * GATEWAY_INTERFACE                                       : CGI/1.2
    * HTTP_ACCEPT                                             : text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
    * HTTP_ACCEPT_ENCODING                                    : gzip, deflate, br
    * HTTP_ACCEPT_LANGUAGE                                    : en-US,en;q=0.9
    * HTTP_CONNECTION                                         : close
    * HTTP_COOKIE                                             : cookies_accepted=true; ahoy_visitor=706aaee0-ee47-456f-9941-2a4cbdd8156a; ahoy_visit=b626df9d-9de7-4afd-b0a2-841408475dab; _r_solutions_session=7Lduf4i0jxN9tl%2Bfjf3byNE09WM9m8w3ZALkfw8n6bSF6c8mL2zG7ZbqOrMfFLQssV%2BjtqpThTkHv0D6kYgsTRUf0VRS5AAlFhFLrAq%2Bl2gkszUcjxKCmDobqyH3DMoUemkpyYWtd8gJvatoCDo8ye7KLs6rDhvzkj%2BzDVzxG0e95TNWucvBYm6cvUO0i2q9Rxnilzw3L40r9oKDTyDC%2FEfUpDJjW%2BQXt0xlPAgIfBDtP5DrmgrC1QlmWyW6cRw9vpaUU7rWMsofwMyMdlDEGDgmvsTKBg4lynL6PeagJgcJSDNCTbRN9UqIIgKNyanyDcuz3N5cIdKxt5F9iHtTBC0JgFt4fg34KVZtTMtw0d6VOdIroELeAgJBr5JLmpmu9nJ0Q2KeDASO1HVqQq4Px3lvyg5qaM2xNTqnApep8lu4%2BRWx9isPV13rEsUFXqViB%2BJo6KB%2BpA97wgBNpjCBkLkNmCy216cTDL%2BUBGmHLu2V7htq%2FvLTBOGMCRreGJUHsPjmoO5dtLm%2Frz7GpE3S0LVV5h9L%2B3ZU2GxTePpsQMISbofJCUZJJNiK83qYZuM7drV34iYGkrzYa2qXOQMf4D6VLl1b1IQa--Om6hQIMYAPHdHdLB--s4w%2FdksFdgI65ZWx4SLHNQ%3D%3D
    * HTTP_HOST                                               : [public.sipshucksip.com](http://public.sipshucksip.com/)
    * HTTP_IF_NONE_MATCH                                      : W/"036d13ab644d7d1fef8001eb219049a5"
    * HTTP_REFERER                                            : https://public.sipshucksip.com/api_namespaces/cocktails
    * HTTP_SEC_CH_UA                                          : "Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"
    * HTTP_SEC_CH_UA_MOBILE                                   : ?0
    * HTTP_SEC_CH_UA_PLATFORM                                 : "macOS"
    * HTTP_SEC_FETCH_DEST                                     : document
    * HTTP_SEC_FETCH_MODE                                     : navigate
    * HTTP_SEC_FETCH_SITE                                     : same-origin
    * HTTP_SEC_FETCH_USER                                     : ?1
    * HTTP_UPGRADE_INSECURE_REQUESTS                          : 1
    * HTTP_USER_AGENT                                         : Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[108.0.0.0](http://108.0.0.0/) Safari/537.36
    * HTTP_VERSION                                            : HTTP/1.0
    * HTTP_X_FORWARDED_FOR                                    : 27.34.22.234
    * HTTP_X_FORWARDED_PROTO                                  : https
    * HTTP_X_REAL_IP                                          : 27.34.22.234
    * ORIGINAL_FULLPATH                                       : /api_namespaces/4/resources/new
    * ORIGINAL_SCRIPT_NAME                                    :
    * PATH_INFO                                               : /api_namespaces/4/resources/new
    * QUERY_STRING                                            :
    * REMOTE_ADDR                                             : 127.0.0.1
    * REQUEST_METHOD                                          : GET
    * REQUEST_PATH                                            : /api_namespaces/4/resources/new
    * REQUEST_URI                                             : /api_namespaces/4/resources/new
    * ROUTES_47210260736080_SCRIPT_NAME                       :
    * SCRIPT_NAME                                             :
    * SERVER_NAME                                             : [public.sipshucksip.com](http://public.sipshucksip.com/)
    * SERVER_PORT                                             : 443
    * SERVER_PROTOCOL                                         : HTTP/1.1
    * SERVER_SOFTWARE                                         : puma 5.6.4 Birdie's Version
    * action_controller.instance                              : #<Comfy::Admin::ApiResourcesController:0x00007fedf4563710>
    * action_dispatch.authenticated_encrypted_cookie_salt     : [FILTERED]
    * action_dispatch.backtrace_cleaner                       : #<Rails::BacktraceCleaner:0x000055dffd19d498>
    * action_dispatch.content_security_policy                 :
    * action_dispatch.content_security_policy_nonce_directives:
    * action_dispatch.content_security_policy_nonce_generator :
    * action_dispatch.content_security_policy_report_only     : false
    * action_dispatch.cookies                                 : #<ActionDispatch::Cookies::CookieJar:0x00007fedf459f7b0>
    * action_dispatch.cookies_digest                          :
    * action_dispatch.cookies_rotations                       : #<ActiveSupport::Messages::RotationConfiguration:0x000055dff8eeb9b0>
    * action_dispatch.cookies_same_site_protection            : #<Proc:0x000055dffe1fe440@/var/www/violet/shared/bundle/ruby/2.6.0/gems/railties-6.1.5/lib/rails/application.rb:636>
    * action_dispatch.cookies_serializer                      : json
    * action_dispatch.encrypted_cookie_cipher                 : [FILTERED]
    * action_dispatch.encrypted_cookie_salt                   : [FILTERED]
    * action_dispatch.encrypted_signed_cookie_salt            : [FILTERED]
    * action_dispatch.http_auth_salt                          : [FILTERED]
    * action_dispatch.key_generator                           : #<ActiveSupport::CachingKeyGenerator:0x000055dffbfdef68>
    * action_dispatch.logger                                  : #<ActiveSupport::Logger:0x000055dffa83e570>
    * action_dispatch.parameter_filter                        : [:passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn]
    * action_dispatch.permissions_policy                      :
    * action_dispatch.redirect_filter                         : []
    * action_dispatch.remote_ip                               : 27.34.22.234
    * action_dispatch.request.content_type                    :
    * action_dispatch.request.formats                         : [#<Mime::Type:0x000055dff8adc720 @synonyms=["application/xhtml+xml"], @symbol=:html, @string="text/html", @hash=1539247684941658837>]
    * action_dispatch.request.parameters                      : {"controller"=>"comfy/admin/api_resources", "action"=>"new", "api_namespace_id"=>"4"}
    * action_dispatch.request.path_parameters                 : {:controller=>"comfy/admin/api_resources", :action=>"new", :api_namespace_id=>"4"}
    * action_dispatch.request.query_parameters                : {}
    * action_dispatch.request.request_parameters              : {}
    * action_dispatch.request.unsigned_session_cookie         : {"session_id"=>"a2772a98b625cddaff0a51261dab2b99", "user_return_to"=>"/api_namespaces/cocktails", "warden.user.user.key"=>[[10], "$2a$12$gUoPjYdnj.KuVW1ERT2fle"], "warden.user.user.session"=>{"last_request_at"=>1673542433}, "site_id"=>1, "_csrf_token"=>"[FILTERED]"}
    * action_dispatch.request_id                              : 65083d87-f670-4088-9d4c-274a93f7bf49
    * action_dispatch.routes                                  : #<ActionDispatch::Routing::RouteSet:0x000055dffda450a0>
    * action_dispatch.secret_key_base                         : [FILTERED]
    * action_dispatch.show_detailed_exceptions                : false
    * action_dispatch.show_exceptions                         : true
    * action_dispatch.signed_cookie_digest                    :
    * action_dispatch.signed_cookie_salt                      : [FILTERED]
    * action_dispatch.use_authenticated_cookie_encryption     : [FILTERED]
    * action_dispatch.use_cookies_with_metadata               : true
    * exception_notifier.exception_data                       : {:current_user=>#<User id: 10, global_admin: false, created_at: "2022-12-22 04:34:13.913985000 +0000", updated_at: "2023-01-12 16:48:32.356461000 +0000", email: "[email protected]", can_manage_web: true, can_manage_email: false, can_manage_users: false, can_manage_blog: false, name: "Sushm...
    * puma.config                                             : #<Puma::Configuration:0x000055dff76e9e20>
    * puma.request_body_wait                                  : 0
    * puma.socket                                             : #<TCPSocket:0x00007fede421fb40>
    * rack.after_reply                                        : []
    * rack.cors                                               : #<Rack::Cors::Result:0x00007fede421ef88>
    * rack.errors                                             : #<IO:0x000055dff6ddc0d0>
    * rack.hijack                                             : #<Puma::Client:0x00007fede421fb18>
    * rack.hijack?                                            : true
    * rack.input                                              : #<Puma::NullIO:0x000055dff79bf258>
    * rack.multiprocess                                       : false
    * rack.multithread                                        : true
    * rack.request.cookie_hash                                : {"cookies_accepted"=>"true", "ahoy_visitor"=>"706aaee0-ee47-456f-9941-2a4cbdd8156a", "ahoy_visit"=>"b626df9d-9de7-4afd-b0a2-841408475dab", "_r_solutions_session"=>"7Lduf4i0jxN9tl+fjf3byNE09WM9m8w3ZALkfw8n6bSF6c8mL2zG7ZbqOrMfFLQssV+jtqpThTkHv0D6kYgsTRUf0VRS5AAlFhFLrAq+l2gkszUcjxKCmDobqyH3DMoUemkpyYWt...
    * rack.request.cookie_string                              : cookies_accepted=true; ahoy_visitor=706aaee0-ee47-456f-9941-2a4cbdd8156a; ahoy_visit=b626df9d-9de7-4afd-b0a2-841408475dab; _r_solutions_session=7Lduf4i0jxN9tl%2Bfjf3byNE09WM9m8w3ZALkfw8n6bSF6c8mL2zG7ZbqOrMfFLQssV%2BjtqpThTkHv0D6kYgsTRUf0VRS5AAlFhFLrAq%2Bl2gkszUcjxKCmDobqyH3DMoUemkpyYWtd8gJvatoCDo8ye7KLs6rDhvzkj%2BzDVzxG0e95TNWucvBYm6cvUO0i2q9Rxnilzw3L40r9oKDTyDC%2FEfUpDJjW%2BQXt0xlPAgIfBDtP5DrmgrC1QlmWyW6cRw9vpaUU7rWMsofwMyMdlDEGDgmvsTKBg4lynL6PeagJgcJSDNCTbRN9UqIIgKNyanyDcuz3N5cIdKxt5F9iHtTBC0JgFt4fg34KVZtTMtw0d6VOdIroELeAgJBr5JLmpmu9nJ0Q2KeDASO1HVqQq4Px3lvyg5qaM2xNTqnApep8lu4%2BRWx9isPV13rEsUFXqViB%2BJo6KB%2BpA97wgBNpjCBkLkNmCy216cTDL%2BUBGmHLu2V7htq%2FvLTBOGMCRreGJUHsPjmoO5dtLm%2Frz7GpE3S0LVV5h9L%2B3ZU2GxTePpsQMISbofJCUZJJNiK83qYZuM7drV34iYGkrzYa2qXOQMf4D6VLl1b1IQa--Om6hQIMYAPHdHdLB--s4w%2FdksFdgI65ZWx4SLHNQ%3D%3D
    * rack.request.query_hash                                 : {}
    * rack.request.query_string                               :
    * rack.run_once                                           : false
    * rack.session                                            : #<ActionDispatch::Request::Session:0x00007fedf4546b60>
    * rack.session.options                                    : #<ActionDispatch::Request::Session::Options:0x00007fedf4546ae8>
    * rack.tempfiles                                          : []
    * rack.url_scheme                                         : https
    * rack.version                                            : [1, 6]
    * warden                                                  : Warden::Proxy:70329991574580 @config={:default_scope=>:user, :scope_defaults=>{}, :default_strategies=>{:user=>[:two_factor_authenticatable, :two_factor_authenticatable, :rememberable]}, :intercept_401=>false, :failure_app=>RSolutionsFailureApp}

-------------------------------
Backtrace:
-------------------------------

  app/helpers/api_forms_helper.rb:48:in `map_non_primitive_data_type'
  app/views/comfy/admin/api_namespaces/_editor.haml:14
  app/views/comfy/admin/api_namespaces/_editor.haml:8
  app/views/comfy/admin/api_namespaces/_editor.haml:7:in `each_with_index'
  app/views/comfy/admin/api_namespaces/_editor.haml:7
  app/views/comfy/admin/api_resources/_form.html.haml:12
  app/views/comfy/admin/api_resources/_form.html.haml:5
  app/views/comfy/admin/api_resources/new.html.haml:3

-------------------------------
Data:
-------------------------------

  * data: {:current_user=>
    #<User id: 10, global_admin: false, created_at: "2022-12-22 04:34:13.913985000 +0000", updated_at: "2023-01-12 16:48:32.356461000 +0000", email: "[email protected]", can_manage_web: true, can_manage_email: false, can_manage_users: false, can_manage_blog: false, name: "Sushmit", moderator: false, can_view_restricted_pages: true, deliver_analytics_report: false, can_manage_subdomain_settings: false, session_timeoutable_in: "1-hour", can_access_admin: true, deliver_error_notifications: false, can_manage_analytics: false, can_manage_files: false, encrypted_otp_secret: nil, encrypted_otp_secret_iv: nil, encrypted_otp_secret_salt: nil, consumed_timestep: nil, otp_required_for_login: false, api_accessibility: {"all_namespaces"=>{"full_access"=>"true"}}, can_access_forum: true, otp_secret: nil>,
   :current_visit=>nil}

donrestarone pushed a commit that referenced this issue Jan 21, 2023
Addresses: #1111

If has_form is unchecked, 

<img width="1727" alt="Screen Shot 2023-01-12 at 8 42 02 PM" src="https://user-images.githubusercontent.com/35935196/212217659-5c5f1f92-8629-4943-8570-ee79e4ea4eee.png">

then the form is not rendered

<img width="1728" alt="Screen Shot 2023-01-13 at 2 43 15 PM" src="https://user-images.githubusercontent.com/35935196/212405547-83913614-8f44-405d-adb3-924df1375bae.png">
donrestarone added a commit that referenced this issue Jan 21, 2023
)

Addresses: #1111

If has_form is unchecked, 

<img width="1727" alt="Screen Shot 2023-01-12 at 8 42 02 PM" src="https://user-images.githubusercontent.com/35935196/212217659-5c5f1f92-8629-4943-8570-ee79e4ea4eee.png">

then the form is not rendered

<img width="1728" alt="Screen Shot 2023-01-13 at 2 43 15 PM" src="https://user-images.githubusercontent.com/35935196/212405547-83913614-8f44-405d-adb3-924df1375bae.png">

Co-authored-by: Er. Ajay Shrestha <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority
Projects
None yet
Development

No branches or pull requests

3 participants