Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Package.xml not getting created #263

Closed
sheldonleelazarus opened this issue Aug 3, 2020 · 15 comments
Closed

Package.xml not getting created #263

sheldonleelazarus opened this issue Aug 3, 2020 · 15 comments

Comments

@sheldonleelazarus
Copy link
Contributor

Hi @amtrack started getting this error message after your last commit when i try to parse a diff command through the force-dev-tool, it doesnt happen on every diff just on some diffs

/usr/local/lib/node_modules/force-dev-tool/node_modules/parse-diff/index.js:81
return file.chunks.push(current);
^

TypeError: Cannot read property 'chunks' of null
at Array.chunk (/usr/local/lib/node_modules/force-dev-tool/node_modules/parse-diff/index.js:81:17)
at parse (/usr/local/lib/node_modules/force-dev-tool/node_modules/parse-diff/index.js:139:13)
at module.exports (/usr/local/lib/node_modules/force-dev-tool/node_modules/parse-diff/index.js:147:5)
at DestroyableTransform._transform (/usr/local/lib/node_modules/force-dev-tool/lib/diff.js:65:15)
at DestroyableTransform.Transform._read (/usr/local/lib/node_modules/force-dev-tool/node_modules/readable-stream/lib/_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (/usr/local/lib/node_modules/force-dev-tool/node_modules/readable-stream/lib/_stream_transform.js:172:83)
at doWrite (/usr/local/lib/node_modules/force-dev-tool/node_modules/readable-stream/lib/_stream_writable.js:428:64)
at writeOrBuffer (/usr/local/lib/node_modules/force-dev-tool/node_modules/readable-stream/lib/_stream_writable.js:417:5)
at DestroyableTransform.Writable.write (/usr/local/lib/node_modules/force-dev-tool/node_modules/readable-stream/lib/_stream_writable.js:334:11)
at Socket.ondata (_stream_readable.js:716:22)
Running Validation of directory config/deployments/51379_release_validation to remote RELEASE
Error: Validation failed.

  • Error in file 'package.xml': No package.xml found
@amtrack
Copy link
Owner

amtrack commented Aug 3, 2020

@sheldonleelazarus Could you please try to play with it to make it reproducible?

So what I've worked on was parsing large files referenced in a git diff (e.g. a CustomObject > 1 MB).
Now this reads as if the diff itself causes problems...

@sheldonleelazarus
Copy link
Contributor Author

@amtrack sent you an email with the steps to replicate

@froucher
Copy link
Contributor

froucher commented Aug 5, 2020

Hi, I have the same issue in my local, I the issue is inside the diff.js file in the Diff.stream function, when parseDiff hasn't at the beginning git diff header, then it can fail.

A sample of git diff header is:

diff --git a/src/classes/sample.cls b/src/classes/sample.cls
index af7583d3..aa3a9968 100644
--- a/src/classes/sample.cls
+++ b/src/classes/sample.cls

I rewrited the Diff.stream code in my local like:

Diff.stream = function(opts) {
	var git = new Git(process.cwd());
	var unpackagedPath = path.join(process.cwd(), 'src');
	opts = opts || {};

	return miss.through.obj(function(diff, enc, cb) {
		var strDiff = diff.toString();

		var index = strDiff.indexOf('diff --git a/');
		if (index <= 0) return cb();

		strDiff = strDiff.substring(index);
		if (!strDiff) return cb();

		var files = parseDiff(strDiff);
		if (files.length <= 0) return cb();

		var containerFrom = new MetadataContainer();
		var containerTo = new MetadataContainer();
		files.forEach(function(file) {
		...
		});

		cb(null, {
			source: containerFrom,
			target: containerTo
		});

	});

I think this code doesn't resolve completely the issue, for example when the git diff header is spliced between different streams.

@amtrack, does this helps? do you need help with the issue?

Regards

@amtrack
Copy link
Owner

amtrack commented Aug 5, 2020

@froucher Yes, please help me on this.
If possible: Can we treat the diff as a string and not as a stream at all?

froucher added a commit to froucher/force-dev-tool that referenced this issue Aug 5, 2020
froucher added a commit to froucher/force-dev-tool that referenced this issue Aug 5, 2020
froucher added a commit to froucher/force-dev-tool that referenced this issue Aug 5, 2020
@froucher
Copy link
Contributor

froucher commented Aug 6, 2020

@sheldonleelazarus, yesterday I do a pull request which can resolve this issue, do you know how to test my branch?

Thanks

@sheldonleelazarus
Copy link
Contributor Author

@froucher yes please let me have a look

@sheldonleelazarus
Copy link
Contributor Author

sheldonleelazarus commented Aug 7, 2020

@froucher i done a quick test and from what i can see when I create changes on an object eg creating new fields, updating field settings on an object more than 3MB the command git diff master testing | force-dev-tool changeset create testingr does not pick up any changes on the object i changed and therefore package resolves to a blank package.xml

I am still running more tests but this is the issue i found with regards to your changes

@froucher
Copy link
Contributor

froucher commented Aug 10, 2020

Hi, @sheldonleelazarus, Can you provide a test case that checks this issue?

froucher added a commit to froucher/force-dev-tool that referenced this issue Sep 22, 2020
froucher added a commit to froucher/force-dev-tool that referenced this issue Sep 22, 2020
'files.length' is always greater or equal to 0

amtrack#263
@Snehil03
Copy link

Hello @froucher - I am also facing same issue as @sheldonleelazarus , I tried to use changeset and ended with only blank pacakge.xml.

I would like to use the git diff and create deployment method for salesforce ci/cd in bitbucket pipelines, I am stuck with creating deployment for the changed meta data.

@amtrack
Copy link
Owner

amtrack commented Oct 14, 2020

@Snehil03 Could you please describe what commands exactly you are running and what version of force-dev-tool you're using?

Also, if possible the output (redacted) of the git diff command would be interesting.

@Snehil03
Copy link

Snehil03 commented Oct 14, 2020

@amtrack

git diff --no-renames feature/lets_fix_cicd master | force-dev-tool changeset create aexp -f
Manifest:

38.0

exported metadata container to ../../config/deployments/aexp

force-dev-tool --version
0.0.0-development

@froucher
Copy link
Contributor

Hi,

Please, can you try with last version 2.8.4?

And if it still does not work, then can you send us the "git diff" result?

git diff --no-renames feature/lets_fix_cicd master > output.diff

If you prefer, then you can send this attachment with a private email.

Thanks

@Snehil03
Copy link

Snehil03 commented Oct 15, 2020 via email

@amtrack
Copy link
Owner

amtrack commented Oct 15, 2020

@Snehil03 Looking at your diff, I see that your Metadata lives in mdapi/src.
force-dev-tool expects the Metadata to live in src.

You can work around this limitation by changing the working directory (to mdapi) and adding a --relative argument to the git command:

cd mdapi
git diff --relative --no-renames feature/lets_fix_cicd master | force-dev-tool changeset create aexp -f

@Snehil03
Copy link

Snehil03 commented Oct 21, 2020 via email

@amtrack amtrack closed this as completed Oct 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants