GithubHelp home page GithubHelp logo

Rack::Lint::Error => a header value must be a String or Array of Strings, but the value of 'content-type' is a NilClass about grape HOT 2 CLOSED

ericproulx avatar ericproulx commented on May 29, 2024
Rack::Lint::Error => a header value must be a String or Array of Strings, but the value of 'content-type' is a NilClass

from grape.

Comments (2)

ericproulx avatar ericproulx commented on May 29, 2024

I understand what's happening. Before #1922, content_type was taken from the base middleware which default to txt/plain.

# lib/grape/middleware/base.rb

def content_type
  content_type_for(env[Grape::Env::API_FORMAT] || options[:format]) || TEXT_HTML
end

Now, some test are now using rack_response instead of error! and this method will call content-type from the endpoint which will be nil if not set explicitely from header.

# lib/grape/dsl/inside_route.rb

def content_type(val = nil)
  if val
    header(Rack::CONTENT_TYPE, val)
  else
    header[Rack::CONTENT_TYPE]
  end
end

I don't think anyone is using rack_response in a rescue_from since its never been documented and I think we should
1 - remove the method from inside_route
2 - make the function private in lib/grape/middleware/error.rb, even though its not accessible anymore within rescue_from

from grape.

dblock avatar dblock commented on May 29, 2024

Good plan. If no specs break we should be good.

from grape.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.