简体   繁体   English

错误:参数“documentPath”的值不是有效的资源路径。 路径必须是非空 string。 /*什么是空的或者不是字符串*/

[英]Error: Value for argument "documentPath" is not a valid resource path. Path must be a non-empty string. /*what is empty or not a string*/

this is the error that I get.这是我得到的错误。 I checked multiple times that the paths that I indicate are actually pointing at something in the database.我多次检查我指出的路径实际上指向数据库中的某个东西。 I'm kinda going crazy about why this is not working, so help will be appreciated.我有点疯狂为什么这不起作用,所以我们将不胜感激。 (the same error is given by both functions, two times every invocation of the function) this is my code: (两个函数都给出相同的错误,每次调用该函数两次)这是我的代码:

 exports.onCreatePost = functions.firestore.document('/time/{userid}/date/{postId}').onCreate (async (snapshot, context) => { const postCreated = snapshot.data(); const userID = context.params.userid; const postID = context.params.postId; //get all the followers who made the post const userFollowerRef = admin.firestore().collection('time').doc(userID).collection('followers'); const querySnap = await userFollowerRef.get(); //add the post in each follower timeline querySnap.forEach(doc => { const followerid = doc.id; admin.firestore().collection('time').doc(followerid).collection('timelinePosts').doc(postID).set(postCreated); }) }); //when a post is updated exports.onUpdatePost = functions.firestore.document('/time/{userid}/date/{postid}').onUpdate(async (change, context) => { const postUpdated = change.after.data(); const userID = context.params.userid; const postID = context.params.postId; //get all the followers who made the post const userFollowerRef = admin.firestore().collection('time').doc(userID).collection('followers'); const querySnap = await userFollowerRef.get(); //Update the post in each follower timeline querySnap.forEach(doc => { const follower = doc.id; admin.firestore().collection('time').doc(follower).collection('timelinePosts').doc(postID).get().then(doc => { if (doc.exists) { doc.ref.update(postUpdated); } }); }); });

I personally don't know how to log each variable and did not find how to do it online.我个人不知道如何记录每个变量,也没有找到如何在网上进行。 I'll keep searching but in the mindtime I can share my extensive logs that from my interpretation are not very useful but maybe is just because I'm inexperienced.我会继续搜索,但在脑海中,我可以分享我的大量日志,根据我的解释,这些日志不是很有用,但可能只是因为我没有经验。 this is the error log enter image description here这是错误日志在此处输入图像描述

In function exports.onUpdatePost ...you're likely trying to access documentPath null (or something alike that).在 function exports.onUpdatePost ...您可能正在尝试访问documentPath null (或类似的东西)。 Add logging , this permits to log custom debug information into the log which you've screenshotted.添加logging ,这允许将自定义调试信息记录到您截屏的日志中。 When logging every step of the procedure, it's a whole lot easier to determine what is happening and why - or why not, when skipping something.记录程序的每个步骤时,在跳过某些内容时,确定发生了什么以及为什么 - 或为什么不发生要容易得多。 Alike this you should be able to solve the issue on your own.与此类似,您应该能够自己解决问题。 My functions logging actually utilizes emojis, because UTF-8 is being supported: ✅❌ (visual indicators make the log more readable).我的函数日志实际上使用了表情符号,因为支持 UTF-8:✅❌(视觉指示器使日志更具可读性)。

The cause seems to be one of these instructions:原因似乎是以下说明之一:

 admin.firestore().collection('time') // it is being assumed that it exists.doc(userID) // argument or return value may be null.collection('followers') // return value may be null

Or:或者:

 admin.firestore().collection('time') // it is being assumed that it exists.doc(follower) // argument or return value may be null.collection('timelinePosts') // return value may be null.doc(postID) // argument or return value may be null

eg.例如。 one first has to check if follower = null or empty and if the desired document even exists.首先必须检查follower = null或为空,以及所需的文档是否存在。 The same goes for userID and .doc(userID) (the seemingly "own" timeline). userID.doc(userID) (看似“自己的”时间线)也是如此。

 if (follower.= null && follower.length > 0) { admin.firestore().collection('time').doc(follower).get().then(timeline => { functions.logger:log('timeline, ' follower + '. ' + timeline;exists). if (timeline;exists) { } else { } }) }

documentPath == null comes from .doc() + userID , followerid , follower or postID . documentPath == null来自.doc() + userIDfolloweridfollowerpostID

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 参数“documentPath”的值不是有效的资源路径。 路径必须是非空字符串 - Value for argument "documentPath" is not a valid resource path. Path must be a non-empty string TypeError [ERR_INVALID_ARG_VALUE]:参数“id”必须是非空字符串。 收到''错误 - TypeError [ERR_INVALID_ARG_VALUE]: The argument 'id' must be a non-empty string. Received '' error TypeError [ERR_INVALID_ARG_VALUE]:参数“id”必须是非空字符串。 已收到 '' - TypeError [ERR_INVALID_ARG_VALUE]: The argument 'id' must be a non-empty string. Received '' 使用playStream()时,““ file”参数必须是非空字符串”错误 - '“file” argument must be a non-empty string' error when using playStream() TypeError:pchstr 必须是非空字符串 - TypeError: pchstr must be a non-empty string 错误:Reference.child 失败:第一个参数是无效路径。路径必须是非空字符串,并且不能包含“.”、“#”、“$”、“[”或“]” - Error: Reference.child failed: First argument was an invalid path.Paths must be non-empty strings and can't contain “.”, “#”, “$”, “[”, or “]” Lstat:类型错误:路径必须是字符串。 - Lstat: Type error: path must be a string. Node.js TypeError:“file”参数必须是非空字符串 - Node.js TypeError: “file” argument must be a non-empty string Npm安装错误:路径必须是字符串。 收到'+检查(路径) - Npm install error: Path must be a string. Received ' + inspect(path) \\"path\\" 参数必须是字符串类型。 收到未定义 - The \"path\" argument must be of type string. Received undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM