Comments (6)
… That‘s really weird. It’s pointed out something that I didn’t know ([].inject(:+) => nil
), but the result array shouldn’t be empty because the extension index should be fully populated before this code gets run. This is going to take some time to figure out, and I’m afraid that I don’t see having that time in the next two weeks.
from ruby-mime-types.
I'm hitting this trying to update this code from mime-types 2.6.2 to 3.1 with ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-linux].
Will update if I find more info.
Stacktrace:
1) VCAP::CloudController::BuildpacksController#delete with async false does not fail if no buildpack bits were ever uploaded
Failure/Error: mime_type = MIME::Types.of(source_path).first.try(:content_type)
NoMethodError:
undefined method `sort' for nil:NilClass
# /usr/local/google/home/jrjohnson/.rvm/gems/ruby-2.3.3/gems/mime-types-3.1/lib/mime/types.rb:152:in `type_for'
# /usr/local/google/home/jrjohnson/.rvm/gems/ruby-2.3.3/gems/mime-types-3.1/lib/mime/types/registry.rb:32:in `type_for'
# ./lib/cloud_controller/blobstore/fog/fog_client.rb:63:in `block in cp_to_blobstore'
# ./lib/cloud_controller/blobstore/fog/fog_client.rb:59:in `open'
# ./lib/cloud_controller/blobstore/fog/fog_client.rb:59:in `cp_to_blobstore'
# ./lib/cloud_controller/blobstore/retryable_client.rb:48:in `block in cp_to_blobstore'
# ./lib/cloud_controller/blobstore/retryable_client.rb:139:in `with_retries'
# ./lib/cloud_controller/blobstore/retryable_client.rb:42:in `cp_to_blobstore'
# ./lib/cloud_controller/blobstore/fog/error_handling_client.rb:55:in `block in cp_to_blobstore'
# ./lib/cloud_controller/blobstore/fog/error_handling_client.rb:61:in `error_handling'
# ./lib/cloud_controller/blobstore/fog/error_handling_client.rb:55:in `cp_to_blobstore'
# ./spec/unit/controllers/runtime/buildpacks_controller_spec.rb:143:in `block (4 levels) in <module:CloudController>'
Repro:
- Clone my fork
git clone https://github.com/johnsonj/cloud_controller_ng
cd cloud_controller_ng
- Create postgres user/database:
sudo -u postgres psql -c "create user pguser with password 'pguser' superuser;"
sudo -u postgres psql -c "create database cc_test;"
- Run spec:
DB=postgres PGPASSWORD="pguser" PGUSER="pguser" bundle exec rspec spec/unit/controllers/runtime/buildpacks_controller_spec.rb
from ruby-mime-types.
+1
from ruby-mime-types.
In our case the issue isn't that @extensions_index is nil, it's that we were passing in a bad parameter that it was previously quiet about.
The calling code essentially did this:
MIME::Types.of(Tempfile.new).first.try(:content_type)
Which is used to create an empty array inside of type_for
a = Array(Tempfile.new) # => []
a.flat_map { |fn| puts 'never called!'; fn } # => []
a.compact # => []
a.inject(:+) # => nil
So ruby learnings from this bug:
[].inject(:+) => nil
[Tempfile.new]
!=Array(Tempfile.new)
from ruby-mime-types.
This is because Array(Tempfile.new)
calls Tempfile#to_a
, delegated from File#to_a
via Enumerable#to_a
.
Sounds like I might need to go back to [arg].flatten
instead of Array(arg)
.
from ruby-mime-types.
Resolved with edf3cd7.
from ruby-mime-types.
Related Issues (20)
- Memory usage/overhead? HOT 56
- Where is audio/mp3?? HOT 1
- perhaps remove link to rubyforge HOT 3
- "text/comma-separated-values" has higher priority than "text/csv"
- Markdown returns wrong content-type. HOT 1
- MIME::Types[/regex/]: Exception thrown for unmatched regex HOT 2
- Uncontrolled growth of the type variants or extension index lists
- Wrong preferred_extension for application/pdf HOT 1
- Splitted 7z file -> mime type "" HOT 1
- Ruby 2.7.0 uses "_1", "_2", "_3" as "numbered parameters" HOT 2
- Nondeterministic order of MIME::Types.type_for HOT 9
- rdoc out of date HOT 1
- Compatibility with file(1)? HOT 1
- syntax error after update version 3.4.0 HOT 3
- How to use MIME::Types.type_for to accurately find the right mime type of file HOT 1
- Random warnings for "Type application/netcdf is already registered as a variant of application/netcdf." HOT 2
- MIME::Type defines #eql? but not #hash HOT 1
- Error in MIME::Types::WarnLogger HOT 3
- Handling of `\n` character in MIME::Types.type_for HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ruby-mime-types.