{"action":"created","comment":{"url":"https://api.github.com/repos/cfengine/core/pulls/comments/45308165","id":45308165,"diff_hunk":"@@ -424,9 +425,43 @@ Promise *DeRefCopyPromise(EvalContext *ctx, const Promise *pp)\n         SeqDestroy(bodies_and_args);\n     }\n \n+    // Add default body for promise body types that are not present\n+    char *bundle_type = pcopy->parent_promise_type->parent_bundle->type;\n+    char *promise_type = pcopy->parent_promise_type->name;\n+    const PromiseTypeSyntax *syntax = PromiseTypeSyntaxGet(bundle_type, promise_type);\n+    AddDefaultBodiesToPromise(ctx, pcopy, syntax);\n+\n+    // Add default body for global body types that are not present\n+    const PromiseTypeSyntax *global_syntax = PromiseTypeSyntaxGet(\"*\", \"*\");\n+    AddDefaultBodiesToPromise(ctx, pcopy, global_syntax);\n+\n     return pcopy;\n }\n \n+// Try to add default bodies to promise for every body type found in syntax\n+static void AddDefaultBodiesToPromise(EvalContext *ctx, Promise *promise, const PromiseTypeSyntax *syntax)\n+{\n+    // iterate over possible constraints\n+    for (int i = 0; syntax->constraints[i].lval; i++)\n+    {\n+        // of type body\n+        if(syntax->constraints[i].dtype == CF_DATA_TYPE_BODY) {\n+            const char *constraint_type = syntax->constraints[i].lval;\n+            // if there is no matching body in this promise\n+            if(!PromiseBundleOrBodyConstraintExists(ctx, constraint_type, promise)) {\n+                const Policy *policy = PolicyFromPromise(promise);\n+                // default format is default:<promise_type>_<body_type>\n+                char* default_body_name = StringConcatenate(4, \"default:\", promise->parent_promise_type->name, \"_\", constraint_type);","path":"libpromises/promises.c","position":38,"original_position":38,"commit_id":"3dc3bf48fb35d63012758089017adaf176d783ca","original_commit_id":"3dc3bf48fb35d63012758089017adaf176d783ca","user":{"login":"kacfengine","id":4037094,"avatar_url":"https://avatars.githubusercontent.com/u/4037094?v=3","gravatar_id":"","url":"https://api.github.com/users/kacfengine","html_url":"https://github.com/kacfengine","followers_url":"https://api.github.com/users/kacfengine/followers","following_url":"https://api.github.com/users/kacfengine/following{/other_user}","gists_url":"https://api.github.com/users/kacfengine/gists{/gist_id}","starred_url":"https://api.github.com/users/kacfengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kacfengine/subscriptions","organizations_url":"https://api.github.com/users/kacfengine/orgs","repos_url":"https://api.github.com/users/kacfengine/repos","events_url":"https://api.github.com/users/kacfengine/events{/privacy}","received_events_url":"https://api.github.com/users/kacfengine/received_events","type":"User","site_admin":false},"body":"``StringConcatenate`` allocates, it needs to be freed.","created_at":"2015-11-19T07:07:43Z","updated_at":"2015-11-19T07:07:43Z","html_url":"https://github.com/cfengine/core/pull/2342#discussion_r45308165","pull_request_url":"https://api.github.com/repos/cfengine/core/pulls/2342","_links":{"self":{"href":"https://api.github.com/repos/cfengine/core/pulls/comments/45308165"},"html":{"href":"https://github.com/cfengine/core/pull/2342#discussion_r45308165"},"pull_request":{"href":"https://api.github.com/repos/cfengine/core/pulls/2342"}}},"pull_request":{"url":"https://api.github.com/repos/cfengine/core/pulls/2342","id":47928427,"html_url":"https://github.com/cfengine/core/pull/2342","diff_url":"https://github.com/cfengine/core/pull/2342.diff","patch_url":"https://github.com/cfengine/core/pull/2342.patch","issue_url":"https://api.github.com/repos/cfengine/core/issues/2342","number":2342,"state":"open","locked":false,"title":"Add default body for all promise type","user":{"login":"peckpeck","id":7976666,"avatar_url":"https://avatars.githubusercontent.com/u/7976666?v=3","gravatar_id":"","url":"https://api.github.com/users/peckpeck","html_url":"https://github.com/peckpeck","followers_url":"https://api.github.com/users/peckpeck/followers","following_url":"https://api.github.com/users/peckpeck/following{/other_user}","gists_url":"https://api.github.com/users/peckpeck/gists{/gist_id}","starred_url":"https://api.github.com/users/peckpeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peckpeck/subscriptions","organizations_url":"https://api.github.com/users/peckpeck/orgs","repos_url":"https://api.github.com/users/peckpeck/repos","events_url":"https://api.github.com/users/peckpeck/events{/privacy}","received_events_url":"https://api.github.com/users/peckpeck/received_events","type":"User","site_admin":false},"body":"If there is a body named files_action_default\r\nit is used as the default action for files promises","created_at":"2015-10-16T15:59:18Z","updated_at":"2015-11-19T07:07:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f22695d273dc1cbf2e99c3853c8d1603a8fb1bb8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cfengine/core/pulls/2342/commits","review_comments_url":"https://api.github.com/repos/cfengine/core/pulls/2342/comments","review_comment_url":"https://api.github.com/repos/cfengine/core/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cfengine/core/issues/2342/comments","statuses_url":"https://api.github.com/repos/cfengine/core/statuses/3dc3bf48fb35d63012758089017adaf176d783ca","head":{"label":"peckpeck:default_body","ref":"default_body","sha":"3dc3bf48fb35d63012758089017adaf176d783ca","user":{"login":"peckpeck","id":7976666,"avatar_url":"https://avatars.githubusercontent.com/u/7976666?v=3","gravatar_id":"","url":"https://api.github.com/users/peckpeck","html_url":"https://github.com/peckpeck","followers_url":"https://api.github.com/users/peckpeck/followers","following_url":"https://api.github.com/users/peckpeck/following{/other_user}","gists_url":"https://api.github.com/users/peckpeck/gists{/gist_id}","starred_url":"https://api.github.com/users/peckpeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peckpeck/subscriptions","organizations_url":"https://api.github.com/users/peckpeck/orgs","repos_url":"https://api.github.com/users/peckpeck/repos","events_url":"https://api.github.com/users/peckpeck/events{/privacy}","received_events_url":"https://api.github.com/users/peckpeck/received_events","type":"User","site_admin":false},"repo":{"id":23580009,"name":"core","full_name":"peckpeck/core","owner":{"login":"peckpeck","id":7976666,"avatar_url":"https://avatars.githubusercontent.com/u/7976666?v=3","gravatar_id":"","url":"https://api.github.com/users/peckpeck","html_url":"https://github.com/peckpeck","followers_url":"https://api.github.com/users/peckpeck/followers","following_url":"https://api.github.com/users/peckpeck/following{/other_user}","gists_url":"https://api.github.com/users/peckpeck/gists{/gist_id}","starred_url":"https://api.github.com/users/peckpeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peckpeck/subscriptions","organizations_url":"https://api.github.com/users/peckpeck/orgs","repos_url":"https://api.github.com/users/peckpeck/repos","events_url":"https://api.github.com/users/peckpeck/events{/privacy}","received_events_url":"https://api.github.com/users/peckpeck/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/peckpeck/core","description":"CFEngine Community","fork":true,"url":"https://api.github.com/repos/peckpeck/core","forks_url":"https://api.github.com/repos/peckpeck/core/forks","keys_url":"https://api.github.com/repos/peckpeck/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/peckpeck/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/peckpeck/core/teams","hooks_url":"https://api.github.com/repos/peckpeck/core/hooks","issue_events_url":"https://api.github.com/repos/peckpeck/core/issues/events{/number}","events_url":"https://api.github.com/repos/peckpeck/core/events","assignees_url":"https://api.github.com/repos/peckpeck/core/assignees{/user}","branches_url":"https://api.github.com/repos/peckpeck/core/branches{/branch}","tags_url":"https://api.github.com/repos/peckpeck/core/tags","blobs_url":"https://api.github.com/repos/peckpeck/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/peckpeck/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/peckpeck/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/peckpeck/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/peckpeck/core/statuses/{sha}","languages_url":"https://api.github.com/repos/peckpeck/core/languages","stargazers_url":"https://api.github.com/repos/peckpeck/core/stargazers","contributors_url":"https://api.github.com/repos/peckpeck/core/contributors","subscribers_url":"https://api.github.com/repos/peckpeck/core/subscribers","subscription_url":"https://api.github.com/repos/peckpeck/core/subscription","commits_url":"https://api.github.com/repos/peckpeck/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/peckpeck/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/peckpeck/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/peckpeck/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/peckpeck/core/contents/{+path}","compare_url":"https://api.github.com/repos/peckpeck/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/peckpeck/core/merges","archive_url":"https://api.github.com/repos/peckpeck/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/peckpeck/core/downloads","issues_url":"https://api.github.com/repos/peckpeck/core/issues{/number}","pulls_url":"https://api.github.com/repos/peckpeck/core/pulls{/number}","milestones_url":"https://api.github.com/repos/peckpeck/core/milestones{/number}","notifications_url":"https://api.github.com/repos/peckpeck/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/peckpeck/core/labels{/name}","releases_url":"https://api.github.com/repos/peckpeck/core/releases{/id}","created_at":"2014-09-02T13:37:46Z","updated_at":"2014-09-02T06:20:14Z","pushed_at":"2015-10-23T08:30:39Z","git_url":"git://github.com/peckpeck/core.git","ssh_url":"git@github.com:peckpeck/core.git","clone_url":"https://github.com/peckpeck/core.git","svn_url":"https://github.com/peckpeck/core","homepage":"https://cfengine.com/community/","size":52012,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cfengine:master","ref":"master","sha":"760a82c4a496240792632571645923651f3d4c91","user":{"login":"cfengine","id":1239823,"avatar_url":"https://avatars.githubusercontent.com/u/1239823?v=3","gravatar_id":"","url":"https://api.github.com/users/cfengine","html_url":"https://github.com/cfengine","followers_url":"https://api.github.com/users/cfengine/followers","following_url":"https://api.github.com/users/cfengine/following{/other_user}","gists_url":"https://api.github.com/users/cfengine/gists{/gist_id}","starred_url":"https://api.github.com/users/cfengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfengine/subscriptions","organizations_url":"https://api.github.com/users/cfengine/orgs","repos_url":"https://api.github.com/users/cfengine/repos","events_url":"https://api.github.com/users/cfengine/events{/privacy}","received_events_url":"https://api.github.com/users/cfengine/received_events","type":"Organization","site_admin":false},"repo":{"id":3543548,"name":"core","full_name":"cfengine/core","owner":{"login":"cfengine","id":1239823,"avatar_url":"https://avatars.githubusercontent.com/u/1239823?v=3","gravatar_id":"","url":"https://api.github.com/users/cfengine","html_url":"https://github.com/cfengine","followers_url":"https://api.github.com/users/cfengine/followers","following_url":"https://api.github.com/users/cfengine/following{/other_user}","gists_url":"https://api.github.com/users/cfengine/gists{/gist_id}","starred_url":"https://api.github.com/users/cfengine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfengine/subscriptions","organizations_url":"https://api.github.com/users/cfengine/orgs","repos_url":"https://api.github.com/users/cfengine/repos","events_url":"https://api.github.com/users/cfengine/events{/privacy}","received_events_url":"https://api.github.com/users/cfengine/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cfengine/core","description":"CFEngine Community","fork":false,"url":"https://api.github.com/repos/cfengine/core","forks_url":"https://api.github.com/repos/cfengine/core/forks","keys_url":"https://api.github.com/repos/cfengine/core/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cfengine/core/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cfengine/core/teams","hooks_url":"https://api.github.com/repos/cfengine/core/hooks","issue_events_url":"https://api.github.com/repos/cfengine/core/issues/events{/number}","events_url":"https://api.github.com/repos/cfengine/core/events","assignees_url":"https://api.github.com/repos/cfengine/core/assignees{/user}","branches_url":"https://api.github.com/repos/cfengine/core/branches{/branch}","tags_url":"https://api.github.com/repos/cfengine/core/tags","blobs_url":"https://api.github.com/repos/cfengine/core/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cfengine/core/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cfengine/core/git/refs{/sha}","trees_url":"https://api.github.com/repos/cfengine/core/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cfengine/core/statuses/{sha}","languages_url":"https://api.github.com/repos/cfengine/core/languages","stargazers_url":"https://api.github.com/repos/cfengine/core/stargazers","contributors_url":"https://api.github.com/repos/cfengine/core/contributors","subscribers_url":"https://api.github.com/repos/cfengine/core/subscribers","subscription_url":"https://api.github.com/repos/cfengine/core/subscription","commits_url":"https://api.github.com/repos/cfengine/core/commits{/sha}","git_commits_url":"https://api.github.com/repos/cfengine/core/git/commits{/sha}","comments_url":"https://api.github.com/repos/cfengine/core/comments{/number}","issue_comment_url":"https://api.github.com/repos/cfengine/core/issues/comments{/number}","contents_url":"https://api.github.com/repos/cfengine/core/contents/{+path}","compare_url":"https://api.github.com/repos/cfengine/core/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cfengine/core/merges","archive_url":"https://api.github.com/repos/cfengine/core/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cfengine/core/downloads","issues_url":"https://api.github.com/repos/cfengine/core/issues{/number}","pulls_url":"https://api.github.com/repos/cfengine/core/pulls{/number}","milestones_url":"https://api.github.com/repos/cfengine/core/milestones{/number}","notifications_url":"https://api.github.com/repos/cfengine/core/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cfengine/core/labels{/name}","releases_url":"https://api.github.com/repos/cfengine/core/releases{/id}","created_at":"2012-02-25T09:19:05Z","updated_at":"2015-11-16T20:08:13Z","pushed_at":"2015-11-19T06:21:55Z","git_url":"git://github.com/cfengine/core.git","ssh_url":"git@github.com:cfengine/core.git","clone_url":"https://github.com/cfengine/core.git","svn_url":"https://github.com/cfengine/core","homepage":"https://cfengine.com/community/","size":58336,"stargazers_count":227,"watchers_count":227,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":139,"mirror_url":null,"open_issues_count":28,"forks":139,"open_issues":28,"watchers":227,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cfengine/core/pulls/2342"},"html":{"href":"https://github.com/cfengine/core/pull/2342"},"issue":{"href":"https://api.github.com/repos/cfengine/core/issues/2342"},"comments":{"href":"https://api.github.com/repos/cfengine/core/issues/2342/comments"},"review_comments":{"href":"https://api.github.com/repos/cfengine/core/pulls/2342/comments"},"review_comment":{"href":"https://api.github.com/repos/cfengine/core/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cfengine/core/pulls/2342/commits"},"statuses":{"href":"https://api.github.com/repos/cfengine/core/statuses/3dc3bf48fb35d63012758089017adaf176d783ca"}}}}