The server cannot process the request due to a client error.
diff --git a/bin/dev b/bin/dev
new file mode 100755
index 00000000000..5f91c205453
--- /dev/null
+++ b/bin/dev
@@ -0,0 +1,2 @@
+#!/usr/bin/env ruby
+exec "./bin/rails", "server", *ARGV
diff --git a/bin/setup b/bin/setup
index 84cd6312957..be3db3c0d62 100755
--- a/bin/setup
+++ b/bin/setup
@@ -2,7 +2,6 @@
require "fileutils"
APP_ROOT = File.expand_path("..", __dir__)
-APP_NAME = "otwarchive"
def system!(*args)
system(*args, exception: true)
@@ -14,7 +13,6 @@ FileUtils.chdir APP_ROOT do
# Add necessary setup steps to this file.
puts "== Installing dependencies =="
- system! "gem install bundler --conservative"
system("bundle check") || system!("bundle install")
# puts "\n== Copying sample files =="
@@ -28,10 +26,9 @@ FileUtils.chdir APP_ROOT do
puts "\n== Removing old logs and tempfiles =="
system! "bin/rails log:clear tmp:clear"
- puts "\n== Restarting application server =="
- system! "bin/rails restart"
-
- # puts "\n== Configuring puma-dev =="
- # system "ln -nfs #{APP_ROOT} ~/.puma-dev/#{APP_NAME}"
- # system "curl -Is https://#{APP_NAME}.test/up | head -n 1"
+ unless ARGV.include?("--skip-server")
+ puts "\n== Starting development server =="
+ STDOUT.flush # flush the output before exec(2) so that it displays
+ exec "bin/dev"
+ end
end
diff --git a/config/application.rb b/config/application.rb
index 6144a8695a1..4fa20ff258e 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -22,7 +22,7 @@ class Application < Rails::Application
# These settings can be overridden in specific environments using the files
# in config/environments, which are processed later.
- config.load_defaults 7.2
+ config.load_defaults 8.0
%w[
app/models/challenge_models
@@ -105,9 +105,6 @@ class Application < Rails::Application
# Use Resque to run ActiveJobs (including sending delayed mail):
config.active_job.queue_adapter = :resque
- # TODO: Remove with Rails 8.0 where this option will be deprecated
- config.active_job.enqueue_after_transaction_commit = :always
-
config.active_model.i18n_customize_full_message = true
config.action_mailer.default_url_options = { host: ArchiveConfig.APP_HOST, protocol: "https" }
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 894a33f63e0..b8c30aa860c 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -3,9 +3,7 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
- # In the development environment your application's code is reloaded any time
- # it changes. This slows down response time but is perfect for development
- # since you don't have to restart the web server when you make code changes.
+ # Make code changes take effect immediately without server restart.
config.enable_reloading = true
# Do not eager load code on boot.
@@ -17,8 +15,8 @@
# Enable server timing.
config.server_timing = true
- # Enable/disable caching. By default caching is disabled.
- # Run rails dev:cache to toggle caching.
+ # Enable/disable Action Controller caching. By default Action Controller caching is disabled.
+ # Run rails dev:cache to toggle Action Controller caching.
if Rails.root.join("tmp/caching-dev.txt").exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true
@@ -28,7 +26,7 @@
config.cache_store = :mem_cache_store, memcached_servers,
{ namespace: "ao3-v2-dev", compress: true, pool: { size: 10 } }
config.public_file_server.headers = {
- "Cache-Control" => "public, max-age=#{2.days.to_i}"
+ "cache-control" => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false
@@ -42,28 +40,21 @@
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
- # Disable caching for Action Mailer templates even if Action Controller
- # caching is enabled.
+ # Make template changes take effect immediately.
config.action_mailer.perform_caching = false
- # Enable mailer previews at http://localhost:3000/rails/mailers.
- config.action_mailer.show_previews = true
-
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
- # Raise exceptions for disallowed deprecations.
- config.active_support.disallowed_deprecation = :raise
-
- # Tell Active Support which deprecation messages to disallow.
- config.active_support.disallowed_deprecation_warnings = []
-
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true
+ # Append comments with runtime information tags to SQL queries in logs.
+ config.active_record.query_log_tags_enabled = true
+
# Highlight code that enqueued background job in logs.
config.active_job.verbose_enqueue_logs = true
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 6297a710732..7d893b15edc 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -1,5 +1,3 @@
-require "active_support/core_ext/integer/time"
-
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
@@ -8,14 +6,13 @@
# Code is not reloaded between requests.
config.enable_reloading = false
- # Eager load code on boot. This eager loads most of Rails and
- # your application in memory, allowing both threaded web servers
- # and those relying on copy on write to perform better.
- # Rake tasks automatically ignore this option for performance.
+ # Eager load code on boot for better performance and memory savings (ignored by Rake tasks).
config.eager_load = true
- # Full error reports are disabled and caching is turned on.
+ # Full error reports are disabled.
config.consider_all_requests_local = false
+
+ # Turn on fragment caching in view templates.
config.action_controller.perform_caching = true
# Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment
@@ -74,10 +71,10 @@
# config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info")
config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "error")
- # Use a different cache store in production.
+ # Replace the default in-process memory cache store with a durable alternative.
# config.cache_store = :mem_cache_store
- # Use a real queuing backend for Active Job (and separate queues per environment).
+ # Replace the default in-process and non-durable queuing backend for Active Job.
# config.active_job.queue_adapter = :resque
# config.active_job.queue_name_prefix = "otwarchive_production"
@@ -102,13 +99,14 @@
config.active_record.dump_schema_after_migration = false
# Only use :id for inspections in production.
- # config.active_record.attributes_for_inspect = [:id]
+ # config.active_record.attributes_for_inspect = [ :id ]
# Enable DNS rebinding protection and other `Host` header attacks.
# config.hosts = [
# "example.com", # Allow requests from example.com
# /.*\.example\.com/ # Allow requests from subdomains like `www.example.com`
# ]
+ #
# Skip DNS rebinding protection for the default health check endpoint.
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
end
diff --git a/config/environments/test.rb b/config/environments/test.rb
index b7395ff1adf..5244359bdc5 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -17,8 +17,8 @@
# loading is working properly before deploying your code.
config.eager_load = ENV["CI"].present?
- # Configure public file server for tests with Cache-Control for performance.
- config.public_file_server.headers = { "Cache-Control" => "public, max-age=#{1.hour.to_i}" }
+ # Configure public file server for tests with cache-control for performance.
+ config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.hour.to_i}" }
# Show full error reports and enable caching.
config.consider_all_requests_local = true
@@ -57,12 +57,6 @@
config.action_controller.default_url_options = { host: "www.example.com", port: nil }
config.action_mailer.default_url_options = config.action_controller.default_url_options.merge(protocol: "https")
- # Raise exceptions for disallowed deprecations.
- config.active_support.disallowed_deprecation = :raise
-
- # Tell Active Support which deprecation messages to disallow.
- config.active_support.disallowed_deprecation_warnings = []
-
# Raises error for missing translations.
# config.i18n.raise_on_missing_translations = true
diff --git a/config/initializers/active_job_enqueue_after_commit.rb b/config/initializers/active_job_enqueue_after_commit.rb
new file mode 100644
index 00000000000..5c2ffa36c09
--- /dev/null
+++ b/config/initializers/active_job_enqueue_after_commit.rb
@@ -0,0 +1,7 @@
+# always enable enqueue_after_transaction_commit
+# TODO: remove for rails 8.2! https://github.com/rails/rails/commit/a477a3273c3c71305cc8ae1835638dc75184ad9d
+Rails.application.config.after_initialize do
+ ActiveSupport.on_load(:active_job) do
+ ActiveJob::Base.enqueue_after_transaction_commit = true
+ end
+end
diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb
index 63b12954396..538625f15f8 100644
--- a/config/initializers/filter_parameter_logging.rb
+++ b/config/initializers/filter_parameter_logging.rb
@@ -4,7 +4,8 @@
# Use this to limit dissemination of sensitive information.
# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors.
Rails.application.config.filter_parameters += [
- :content, :passw, :terms_of_service_non_production, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn
+ :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc,
+ :content, :terms_of_service_non_production
]
# IMPORTANT! Rails.application.config.filter_parameters must be set *above* in this file
diff --git a/config/routes.rb b/config/routes.rb
index d41f9761074..08b09f134c9 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -48,11 +48,12 @@
#### ERRORS ####
- get '/403', to: 'errors#403'
- get '/404', to: 'errors#404'
- get '/422', to: 'errors#422'
- get '/500', to: 'errors#500'
- get '/auth_error', to: 'errors#auth_error'
+ get "/400", to: "errors#400"
+ get "/403", to: "errors#403"
+ get "/404", to: "errors#404"
+ get "/422", to: "errors#422"
+ get "/500", to: "errors#500"
+ get "/auth_error", to: "errors#auth_error"
get "/timeout_error", to: "errors#timeout_error"
#### DOWNLOADS ####
diff --git a/public/400.html b/public/400.html
new file mode 100644
index 00000000000..d9123dbfd29
--- /dev/null
+++ b/public/400.html
@@ -0,0 +1,155 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Bad Request | Archive of Our Own
+
+
+
+
+
+
+
+
+
+
+
+
+
+
The server cannot process the request due to a client error.
+
If you are receiving this error repeatedly, please contact Support. In the form, please include a link to the page you're trying to reach and how you're trying to reach this page.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/spec/controllers/errors_controller_spec.rb b/spec/controllers/errors_controller_spec.rb
index 0504f2b248c..c699a197da0 100644
--- a/spec/controllers/errors_controller_spec.rb
+++ b/spec/controllers/errors_controller_spec.rb
@@ -1,6 +1,14 @@
require "spec_helper"
describe ErrorsController do
+ describe "400" do
+ it "returns an HTML 400 page" do
+ get :"400"
+ expect(response.status).to eq(400)
+ expect(response.header["Content-Type"]).to eq("text/html; charset=utf-8")
+ end
+ end
+
describe "404" do
it "returns an HTML 404 page for .html" do
get :"404", params: { format: :html }