ActiveStorage: TypeError Exception: no implicit conversion of String into Hash - rails-activestorage

After Rails update from 6.1 to 7.0.3, I start getting ActiveStorage errors while calling something like
object.document_attachment.url
it throws the error *** TypeError Exception: no implicit conversion of String into Hash
One quick solution is
Rails.application.routes.url_helpers.rails_blob_path(object.document_attachment.attachment, only_path: true)
but I am not in the favor of that, looking for the actual reason for the change.

Related

Python 3: Shared packages: Returning results and errors from imported functions

I am creating a Python 3.4 module (possibly sharing upon PyPi) and I want to clarify what is the proper and expected way of handling results and errors returned from an imported function from my package.
I am reading Effective Python, but I am still confused.
There are so many possibilities, I just want to handle Python 3 results from an imported function properly.
Should the result and error handling of an imported function:
Return result but then throw exception upon error?
Return a tuple of result, error?
And if the preferred choice is tuple, then should:
Upon success, result can be anything (is this correct?), but then should error be None or should it be False?
Upon failure, then should result be None or should it be False, and error should then return internally caught Exception or what?
Thank you for your feedback
You should throw an exception upon error. This enable lot of advance construction like proper object destruction like with the with keyword for instance.
If you raise an exception you don't care about result as your function will not return "in a normal way". So the instruction on the left on your function call will not be executed as well the rest of the try block.

when I run my jsp pgogram I got this exception error type Exception report

type Exception report
message Unable to compile class for JSP:
description The server encountered an internal error that prevented it
from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 44 in the jsp file:
/jsp/ShoppingCart/AddBook.jsp The method getValue(String) is undefined
for the
type HttpServletRequest
int int_BookID,int_CategoryID,int_Price,int_Quantity;
String str_Title, str_Author, str_Publisher,str_Edition,str_Description;
int_BookID=(int)(10000*Math.random()+1);
int_CategoryID=Integer.parseInt(request.getValue("cat"));
str_Title=request.getParameter("title");
str_Author=request.getParameter("author");
str_Publisher=request.getParameter("pub");
request.getValue("cat") is the problem here.
I suppose the 'cat' is a parameter.
Instead , use request.getParameter("cat")
PS- I recommend you to read the basics of JSP first try the HeadFirst series.

'NSInternalInconsistencyException', reason: is not a subclass of NSManagedObject.'

In my APP I have a really simple model with just two classes. One of those is CDAttribute.
This APP is in the store and was working. Now I tested it the fist time with xCode 6 today and put a new version of it on my iPad. Now I get this error
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '"CDAttribute" is not a subclass of NSManagedObject.'
*** First throw call stack:
(0x18342e084 0x193e800e4 0x1830f5350 0x183113f94 0x10004450c 0x100043410 0x1833d4434 0x1833137e0 0x18420b6c0 0x10003f758 0x187e3f104 0x187e432dc 0x187e47624 0x187e46b00 0x187e46a58 0x187e3a38c 0x18b605640 0x1833e6360 0x1833e5468 0x1833e3a8c 0x183311664 0x18c41f5a4 0x187c16984 0x10004d0a0 0x1944eea08)
libc++abi.dylib: terminating with uncaught exception of type NSException
calling this fuction
CDAttribute *attr = (CDAttribute *)[NSEntityDescription insertNewObjectForEntityForName:#"CDAttribute" inManagedObjectContext:self.managedObjectContext];
Which I can't understand because I didn't touch the model nor the code.
It seems like CDAttribute is reserved in iOS8. I changed the Classname (not the table name in the model, because then I'd probably loose all my entries when I update to this version) to SIAttribute and it worked.
It was the solution, however I'd be intrested if its really reserved and where it is documented.

com.facebook.presto.server.PrestoServer Guice creation errors

I got the following error when trying to start presto server, how can I diagnose what property is malformed or something else? Thanks.
config file:
coordinator=true
datasources=jmx
http-server.http.port=8080
presto-metastore.db.type=h2
presto-metastore.db.filename=var/db/MetaStore
task.max-memory=1GB
discovery-server.enabled=true
discovery.uri=http://localhost:8080
exception is
2013-11-11T11:11:39.582-0800 ERROR main com.facebook.presto.server.PrestoServer Guice creation errors:
1) Error: Constraint violation with property prefix '': environment is malformed (for class io.airlift.node.NodeConfig)
at io.airlift.node.NodeModule.configure(NodeModule.java:34)
1 error
com.google.inject.CreationException: Guice creation errors:
1) Error: Constraint violation with property prefix '': environment is malformed (for class io.airlift.node.NodeConfig)
at io.airlift.node.NodeModule.configure(NodeModule.java:34)
1 error
at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:435) ~[guice-3.0.jar:na]
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:154) ~[guice-3.0.jar:na]
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106) ~[guice-3.0.jar:na]
at com.google.inject.Guice.createInjector(Guice.java:95) ~[guice-3.0.jar:na]
at io.airlift.bootstrap.Bootstrap.initialize(Bootstrap.java:277) ~[bootstrap-0.84.jar:0.84]
at com.facebook.presto.server.PrestoServer.run(PrestoServer.java:137) ~[presto-server-0.52.jar:0.52]
at com.facebook.presto.server.PrestoServer.main(PrestoServer.java:50) ~[presto-server-0.52.jar:0.52]
Apologies for the very unfriendly and unhelpful error message. This is on our list of things to fix.
The error "environment is malformed" means that the node.environment property (in the node.properties file) is set but fails to match the following regular expression: [a-z0-9][_a-z0-9]*. In other words, it must be lowercase, start with an alphanumeric character, and have only alphanumeric or underscores in subsequent characters.
Try a simpler name like test or production.
Not that it's of consolation, but I am getting something similar on Centos:
1) Error: Constraint violation with property prefix '': environment
may not be null (for class io.airlift.node.NodeConfig) at
io.airlift.node.NodeModule.configure(NodeModule.java:34)
1 error com.google.inject.CreationException: Guice creation errors:

VS2012 error every time I start. Message is not helpful - any suggestions?

WHen I start VS2012 I always get an exception tellng me to look at ActivityLog.xml. Here is what I see- useless to me. Hoping someone else has seen this before.
Also - VS2012 eats 100% of the CPU on the machine at time. Hoping the two are related and fixable.
System.ComponentModel.Composition.CompositionException: The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) The current type, SquaredInfinity.Foundation.Configuration.Services.IConfigurationService, is an interface and cannot be constructed. Are you missing a type mapping?
Resulting in: Resolution of the dependency failed, type = "SquaredInfinity.Foundation.Configuration.Services.IConfigurationService", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, SquaredInfinity.Foundation.Configuration.Services.IConfigurationService, is an interface and cannot be constructed. Are you missing a type mapping?
-----------------------------------------------
At the time of the exception, the container was:
Resolving SquaredInfinity.Foundation.Configuration.Services.IConfigurationService,(none)
Resulting in: An exception occurred while trying to create an instance of type '#Btb.#Rtb'.
Resulting in: Cannot activate part '#Btb.#Rtb'.
Element: #Btb.#Rtb --> #Btb.#Rtb
Resulting in: Cannot get export '#Btb.#Rtb (ContractName="Microsoft.VisualStudio.Text.Classification.IClassifierProvider")' from part '#Btb.#Rtb'.
Element: #Btb.#Rtb (ContractName="Microsoft.VisualStudio.Text.Classification.IClassifierProvider") --> #Btb.#Rtb
at System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(CatalogPart part, ExportDefinition export, Boolean isSharedPart)
at System.ComponentModel.Composition.Hosting.CatalogExportProvider.CatalogExport.GetExportedValueCore()
at System.ComponentModel.Composition.Primitives.Export.get_Value()
at System.ComponentModel.Composition.ExportServices.GetCastedExportedValue[T](Export export)
at System.ComponentModel.Composition.ExportServices.<>c__DisplayClass42.<CreateStronglyTypedLazyOfTM>b__1()
at System.Lazy1.CreateValue()
at System.Lazy1.LazyInitValue()
at System.Lazy1.get_Value()
at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.InvokeMatchingFactories[TExtensionInstance,TExtensionFactory,TMetadataView](IEnumerable1 lazyFactories, Func2 getter, IContentType dataContentType, Object errorSource)
Is your VSCommands extension up to date?
There was a compatibility issue which could produce similar stack trace, and it was fixed in latest release.

Resources