I am struggling with this issue:
InvalidArgumentException: The URI '' is invalid.
You must use a valid URI scheme. in Drupal\Core\Url::fromUri()
(line 284 of core/lib/Drupal/Core/Url.php).
How can I fix this?
You are passing a blank uri into the method. It is complaining about missing a scheme (eg. http:// or https://, or an internal scheme eg: internal:/)
So either you are explicitly passing a blank, or something isn't being set correctly. However, it does not seem to be null.
I had similar issue in Drupal 8 site, please make sure your files directory path is set correctly
I my case files path was Private and it was not configured in settings.php.
$settings['file_private_path'] = 'sites/default/files/private';
From the looks of the source code for the fromUri() function it would appear as though it throws that error when the PHP parse_url function returns an empty scheme:
... elseif (empty($uri_parts['scheme'])) { throw new \InvalidArgumentException("The URI '$uri' is invalid. You must use a valid URI scheme."); ...
From what I can gather in your question you seem to be providing an empty/null value to the fromUri method which is in turn causing the script to error when it attempts to parse the value. So I'd imagine that you'd need to do some kind of check before passing it to the fromUri function.
An example of how to use this method is helpfully provided in the comments section of the fromUri page: https://api.drupal.org/comment/61905#comment-61905
In case your URI is public://, then use:
\Drupal::service('file_url_generator')->generate($file->getFileUri())
Related
I have been following the blog post here and I've made it to testing the function on my local environment. I've copy and pasted everything form the blog into my text editor. Nothing in my code is original - but I cannot get it to work! When I try to run it in my local environment, I get this error:
const b = bindings[key].toString();
^
TypeError: Cannot read properties of undefined (reading 'toString')
at PathTemplate.render (/Users/dialogflow-cx/node_modules/google-gax/build/src/pathTemplate.js:114:37)
at SessionsClient.projectLocationAgentSessionPath (/Users/dialogflow-cx/node_modules/#google-cloud/dialogflow-cx/build/src/v3/sessions_client.js:1237:75)
at exports.handler (/Users/Waterfield/dialogflow-cx/functions/dialogflow-detect-intent.protected.js:21:25)
at process.<anonymous> (/Users/dialogflow-cx/node_modules/#twilio/runtime-handler/dist/dev-runtime/internal/functionRunner.js:74:9)
at process.emit (node:events:390:28)
at emit (node:internal/child_process:917:12)
at processTicksAndRejections (node:internal/process/task_queues:84:21)
I don't know where to go from here! Help!
Here your TypeError is "cannot read properties of undefined", that means at least one of your passed arguments is undefined.
As we go through your return error, second line directs to the "projectLocationAgentSessionPath" and this section refers to the "Setup the detectIntentRequest" in the blog .
session: client.projectLocationAgentSessionPath(
context.DIALOGFLOW_CX_PROJECT_ID,
context.DIALOGFLOW_CX_LOCATION,
context.DIALOGFLOW_CX_AGENT_ID,
event.dialogflow_session_id
)
The above error means at least on of the objects that relates to projectId, location, agentId, SessionId is returning undefined.
To resolve the error you have to check whether you are passing correct environment variables the same as .env files or not?
Within the error, we can see that there is a reference to the code you are working on:
at exports.handler (/Users/Waterfield/dialogflow-cx/functions/dialogflow-detect-intent.protected.js:21:25)
This refers to this line:
client.projectLocationAgentSessionPath(
context.DIALOGFLOW_CX_PROJECT_ID,
context.DIALOGFLOW_CX_LOCATION,
context.DIALOGFLOW_CX_AGENT_ID,
event.dialogflow_session_id
)
Following the code through the dialogflow library and then the Google API extensions library shows that ultimately the code is running through the keys of the object that relate to the project, location, agent and session which map to the 4 arguments above. And at least one of them is returning undefined.
Have you added the correct environment variables to your .env file? Are you passing a dialogflow_session_id when you make a request to test this endpoint?
When trying to access a WSDL service, I get the following error:
ValueError: Invalid tag name 'Foo\\Bar\\Baz\\Etc\\V3Port'
The port which is provided through the WSDL-link actually has single backslashes: 'Foo\Bar\Baz\Etc\V3Port'
The ValueError gets raised when zeep calls the apihelpers.pxi method in the lxml library.
Any idea how I can fix this?
(BTW: the script worked fine when I used it 2 months ago. The WSDL-link hasn't changed)
I have found a solution
Before, it was sufficient to do:
from zeep import Client
Now, apparently, I need to explicitly add:
from lxml import etree
Everything works as before now.
Zeep does not like like "/" in values also. It gives invalid tag name error any time it finds any character in value that it does not like. For all such errors, you need to modify as_qname function in utils.py located in root folder of zeep library.
In my case, it was complaining for "/" in value, which is a valid value. I had to add below line to as_qname function.
value = value.replace("/", "-")
Below are first few lines of as_qname after modification
def as_qname(value: str, nsmap, target_namespace=None) -> etree.QName:
"""Convert the given value to a QName"""
value = value.strip() # some xsd's contain leading/trailing spaces
value = value.replace("/", "-") # Added by me.
if ":" in value:
prefix, local = value.split(":")
can you help me to convert this to python 3.5 ? I tried but it don't work. I did the following steps:
I change the package md5 to hashlib
I change all the id = md5.new("%s"%str(clf.get_params())).hexdigest() to id = hashlib.md5(("%s"%str(clf.get_params())).encode('utf-8') ).hexdigest()
but I still have somme problems when I put a directory to these parameters
save_preds="",
save_params=""
save_test_only=""
clf_name="XX"
I have the folowing error when I put something in thise parameters:
TypeError: a bytes-like object is required, not 'str'
Please see the code here:
blend_proba.py
Thanks,
cdk
Replacing
clf_name="XX"
by
clf_name=b"XX"
would convert the strings into objects of type bytes. Whether those changes will be enough, I honestly have no idea.
I am calling watch method of gmail to get updates of my mailbox, but it is giving me error
Google::Apis::ClientError: invalidArgument: topicName required
this is the code
service.watch_user('me','projects/devpush/topics/push')
can any one please tell me what is wrong in this?
I had this same problem and after I consulted the source, I found that you need to build a WatchRequest and pass that in to user_watch, like so:
watch_request = Google::Apis::GmailV1::WatchRequest.new
watch_request.topic_name = 'projects/devpush/topics/push'
service.watch_user('me', watch_request)
I'm not familiar with ruby, but maybe you can try giving the topicName as a named parameter?
service.watch_user('me', topicName: 'projects/devpush/topics/push')
Sorry if I'm wrong, but from the error message, you should add a named parameter.
I am having this issue while using findbyid to get a unique url for a page on my shared hosting. The problem I have is that I keep getting the following error while trying to access the unique page via the Id number of the item on shared hosting(i dont get this issue on localhost):
Error: The action item is not defined in controller ProductsController
Error: Create ProductsController::item() in file: app/Controller/ProductsController.php.
However item is defined in the productscontroller:
public function item($id = null) {
if (!$id) {
throw new NotFoundException(__('product not found'));
}
$items = $this->Product->findById($id);
if (!$items) {
throw new NotFoundException(__('Invalid post'));
}
$this->set('item', $items);
}
you can see the problem at this url: http://entourmag.com/hava/products/item/39
it works on localhost via wamp so I am not sure what the problem is.
Thanks in advance
Well I figured out the issue. The problem was with the files uploaded; the files uploaded were incomplete or missing, when I check the ProductsController.php file I realised that most of the code was missing. Reuploading solved the problem.
For others with problematic internet connection take note of this while coding.
Error: A Database connection using "Mysql" was missing or unable to connect.
The database server returned this error: SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: NO)
Notice: If you want to customize this error message, create app/View/Errors/missing_connection.ctp
I think you have not created/configured your database.php in app/Config
I am using cakephp 3.8 and I figure out one possible cause of this kind of messages.
In my case, I am expecting the __construct method is responsible for creating the base class.
And the solution is to use initialize method, like so:
function initialize() {
parent::initialize();
}
In conclusion, we should more carefully read the documentation, it clearly stated here and please take time to do the 20 min cms tutorial