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

Unpermitted parameter: :id #3154

Open
jcoyne opened this issue May 14, 2024 · 8 comments
Open

Unpermitted parameter: :id #3154

jcoyne opened this issue May 14, 2024 · 8 comments

Comments

@jcoyne
Copy link
Member

jcoyne commented May 14, 2024

This seems to just be a warning, but it's in red and so a bit disconcerting.

Started GET "/catalog/d71f88d6-5f98-4aab-93f7-5b39a7028057" for 127.0.0.1 at 2024-05-14 09:42:29 -0400
Processing by CatalogController#show as HTML
  Parameters: {"id"=>"d71f88d6-5f98-4aab-93f7-5b39a7028057"}
Unpermitted parameter: :id. Context: { controller: CatalogController, action: show, request: #<ActionDispatch::Request:0x0000000107d282c0>, params: {"controller"=>"catalog", "action"=>"show", "id"=>"d71f88d6-5f98-4aab-93f7-5b39a7028057"} }

...
Completed 200 OK in 95ms (Views: 45.6ms | ActiveRecord: 0.2ms | Allocations: 38415)

@JeremyDuncan
Copy link

I ran across this issue for id and a few other params. The following code in the Catalog Controller resolved the error and deprecation messages for me.

  configure_blacklight do |config|
    ###############################################
    ##  Permit additional params for blacklight  ##
    ###############################################
    config.search_state_fields += [ :id ]
  end

@jcoyne
Copy link
Member Author

jcoyne commented Feb 6, 2025

@JeremyDuncan id is not part of the search state. The search state is the parameters that define which search and filters you have currently applied.

@JeremyDuncan
Copy link

So you tried it and it did not resolve your issue?

@jcoyne
Copy link
Member Author

jcoyne commented Feb 6, 2025

There isn't much of an issue here. It's warning, and I think it can safely be ignored.

@JeremyDuncan
Copy link

So you tried it and it did not resolve your warning?

@jcoyne
Copy link
Member Author

jcoyne commented Feb 6, 2025

What version of Rails are you running on? I'm unable to duplicate this on the main branch with Rails 8.0.1

08:41:35 web.1  | Processing by CatalogController#show as HTML
08:41:35 web.1  |   Parameters: {"id"=>"2007020969"}
08:41:35 web.1  | Solr query: get get {:qt=>nil, :ids=>"2007020969"}
08:41:35 web.1  | Solr fetch (16.2ms)
08:41:35 web.1  |   Rendering layout /Users/jcoyne85/workspace/projectblacklight/blacklight/app/views/layouts/catalog_result.html.erb
08:41:35 web.1  |   Rendering /Users/jcoyne85/workspace/projectblacklight/blacklight/app/views/catalog/show.html.erb within layouts/catalog_result
08:41:35 web.1  |   Search Load (0.1ms)  SELECT "searches".* FROM "searches" WHERE "searches"."id" = 1 AND "searches"."id" = 1 ORDER BY updated_at desc LIMIT 1 /*action='show',application='Internal',controller='catalog'*/
08:41:35 web.1  |   Rendered /Users/jcoyne85/workspace/projectblacklight/blacklight/app/views/catalog/_show_main_content.html.erb (Duration: 13.0ms | GC: 1.1ms)
08:41:35 web.1  |   User Load (0.1ms)  SELECT "users".* FROM "users" WHERE "users"."email" = 'guest_81331cf2-fbd4-4bd5-bd63-1cfe6140f3c2@example.com' LIMIT 1 /*action='show',application='Internal',controller='catalog'*/
08:41:35 web.1  |   Bookmark Load (0.0ms)  SELECT "bookmarks".* FROM "bookmarks" WHERE "bookmarks"."user_id" = 2 AND "bookmarks"."user_type" = 'User' AND "bookmarks"."document_type" = 'SolrDocument' AND "bookmarks"."document_id" = '2007020969' /*action='show',application='Internal',controller='catalog'*/
08:41:35 web.1  |   Rendered /Users/jcoyne85/workspace/projectblacklight/blacklight/app/views/catalog/show.html.erb within layouts/catalog_result (Duration: 20.8ms | GC: 1.5ms)
08:41:35 web.1  |   Rendering /Users/jcoyne85/workspace/projectblacklight/blacklight/app/views/layouts/blacklight/base.html.erb
08:41:35 web.1  |   Bookmark Count (0.0ms)  SELECT COUNT(*) FROM "bookmarks" WHERE "bookmarks"."user_id" = 2 AND "bookmarks"."user_type" = 'User' /*action='show',application='Internal',controller='catalog'*/
08:41:35 web.1  |   ↳ app/components/blacklight/top_navbar_component.html.erb:9:in `call'
08:41:35 web.1  |   Rendered /Users/jcoyne85/workspace/projectblacklight/blacklight/app/views/blacklight/nav/_bookmark.html.erb (Duration: 0.5ms | GC: 0.0ms)
08:41:35 web.1  |   Rendered /Users/jcoyne85/workspace/projectblacklight/blacklight/app/views/blacklight/nav/_search_history.html.erb (Duration: 0.1ms | GC: 0.0ms)
08:41:35 web.1  |   Rendered /Users/jcoyne85/workspace/projectblacklight/blacklight/app/views/shared/_user_util_links.html.erb (Duration: 0.7ms | GC: 0.0ms)
08:41:35 web.1  |   Rendered /Users/jcoyne85/workspace/projectblacklight/blacklight/app/views/shared/_flash_msg.html.erb within shared/_flash_messages (Duration: 0.0ms | GC: 0.0ms)
08:41:35 web.1  |   Rendered /Users/jcoyne85/workspace/projectblacklight/blacklight/app/views/shared/_footer.html.erb (Duration: 0.0ms | GC: 0.0ms)
08:41:35 web.1  |   Rendered /Users/jcoyne85/workspace/projectblacklight/blacklight/app/views/shared/_modal.html.erb (Duration: 0.0ms | GC: 0.0ms)
08:41:35 web.1  |   Rendered /Users/jcoyne85/workspace/projectblacklight/blacklight/app/views/layouts/blacklight/base.html.erb (Duration: 5.9ms | GC: 0.3ms)
08:41:35 web.1  |   Rendered layout /Users/jcoyne85/workspace/projectblacklight/blacklight/app/views/layouts/catalog_result.html.erb (Duration: 26.9ms | GC: 1.8ms)
08:41:35 web.1  | Completed 200 OK in 122ms (Views: 27.2ms | ActiveRecord: 0.2ms (4 queries, 0 cached) | GC: 6.5ms)

@JeremyDuncan
Copy link

Initially I was getting Unpermitted parameter: :id. in blacklight (7.36.2) when CatalogController#show executed.
The above snippet I provided resolved that for me.

@jcoyne
Copy link
Member Author

jcoyne commented Feb 6, 2025

@JeremyDuncan Yes, that will cause the warning to disappear, but it may have unintended consequences as you've added parameters to the search state that do not belong in it.

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

No branches or pull requests

2 participants