Skip to content
This repository was archived by the owner on Jan 19, 2024. It is now read-only.

Conversation

@Toxicable
Copy link

No description provided.

Copy link
Contributor

@ocombe ocombe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see where you would fix errors like this one:

[error] Error: Reference.set failed: First argument  contains an invalid key (bundle.br) in property 'payload.core.6%2E0%2Ex.484233f6c1d47dacde3a9111d0c79113bd2bb9ea.hello_world'.  Keys must be non-empty strings and can't contain ".", "#", "$", "/", "[", or "]"
    at /user_code/node_modules/firebase-admin/node_modules/@firebase/database/dist/index.node.cjs.js:1469:27
    at Object.forEach (/user_code/node_modules/firebase-admin/node_modules/@firebase/database/node_modules/@firebase/util/dist/index.node.cjs.js:835:13)
    at validateFirebaseData (/user_code/node_modules/firebase-admin/node_modules/@firebase/database/dist/index.node.cjs.js:1462:14)
    at /user_code/node_modules/firebase-admin/node_modules/@firebase/database/dist/index.node.cjs.js:1479:13
    at Object.forEach (/user_code/node_modules/firebase-admin/node_modules/@firebase/database/node_modules/@firebase/util/dist/index.node.cjs.js:835:13)
    at validateFirebaseData (/user_code/node_modules/firebase-admin/node_modules/@firebase/database/dist/index.node.cjs.js:1462:14)
    at validateFirebaseDataArg (/user_code/node_modules/firebase-admin/node_modules/@firebase/database/dist/index.node.cjs.js:1421:5)
    at Reference.set (/user_code/node_modules/firebase-admin/node_modules/@firebase/database/dist/index.node.cjs.js:13963:9)
    at SizeTask.<anonymous> (/user_code/dist/plugins/size.js:128:31)
    at next (native)
    at /user_code/dist/plugins/size.js:7:71
    at __awaiter (/user_code/dist/plugins/size.js:3:12)
    at SizeTask.upsertNewArtifacts (/user_code/dist/plugins/size.js:95:16)
    at SizeTask.<anonymous> (/user_code/dist/plugins/size.js:81:25)
    at next (native)
    at fulfilled (/user_code/dist/plugins/size.js:4:58)
    at process._tickDomainCallback (internal/process/next_tick.js:135:7)

have you checked the script scripts/ci/payload-size.sh to be sure that we don't need to encode anything else?


getRef(path: string): database.Reference {
return this.rtDb.ref(firebasePathEncode(path));
return this.rtDb.ref(path);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you don't encode the path in this function, then it has no use, you might as well remove it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

for(const project of projects) {
for(const branch of context.payload.branches) {
const ref = this.getRef(`/payload/${project}/${branch.name}/${context.payload.commit.sha}`);
const ref = this.getRef(`/payload/${project}/${firebasePathEncode(branch.name)}/${context.payload.commit.sha}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure that we only want to encode the branch name?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/
export function firebasePathEncode(s: string) {
return s.replace(/[\.#\$\[\]]/g, c => '%' + c.charCodeAt(0).toString(16).toUpperCase());
return s.replace(/\./g, '_');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we also replace other forbidden characters?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going off the existing script I don't think so. I think there's other cases where it's needed it should be handled on a case by case basis

let lastNestedItemRef: object | number = artifactsOutput;
// first item is the project name which we've used already
a.contextPath.forEach((path, i) => {
const encodedPath = firebasePathEncode(path);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ocombe The changes here are the ones that are intended to fix the bundle.br issue

Object.keys(object).forEach(k => {
if(typeof object[k] === 'object') {
reconstructArtifacts(object[k], path + '/' + k);
reconstructArtifacts(object[k], path + '/' + firebasePathDecode(k));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can you differentiate between existing "_" from the name, and the one that you added when you did the encode?
for example if the name was "bundle_2.br", it would be encoded into "bundle_2_br" and decoded into "bundle.2.br"
is it a problem?

Copy link
Author

@Toxicable Toxicable May 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bugger.... You're right.
I don't know how you'd get around that, from what I can decipher there's isn't any special handling for this case in the payload-size.sh

@ocombe ocombe merged commit 6e5dc1e into angular:master May 11, 2018
@Toxicable Toxicable deleted the encode-fix branch May 11, 2018 20:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants