AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
fix(github): stop Update Repository (Agent) making private repos public (#16727)
Ibrahim Abuznaid252ea9e53984
diff --git a/bun.lock b/bun.lockindex 400b8946dde..252f58cc410 100644--- a/bun.lock+++ b/bun.lock@@ -3736,7 +3736,7 @@},"packages/pieces/community/github": {"name": "@activepieces/piece-github",- "version": "0.10.1",+ "version": "0.11.0","dependencies": {"@activepieces/core-piece-types": "workspace:*","@activepieces/core-utils": "workspace:*",diff --git a/docs/install/reference/breaking-changes-unreleased.mdx b/docs/install/reference/breaking-changes-unreleased.mdxindex c2c2f2485be..da5e414ab74 100644--- a/docs/install/reference/breaking-changes-unreleased.mdx+++ b/docs/install/reference/breaking-changes-unreleased.mdx@@ -8,6 +8,14 @@ Entries here move to [Breaking Changes](/install/reference/breaking-changes) aut## What has changed?+#### GitHub 0.11.0: Update Repository (Agent) no longer makes private repositories public++When an AI agent used **Update Repository (Agent)** to change something else, such as the description, the agent path filled the three toggles it left out (**Private**, **Has Issues** and **Archived**) with `false` and sent them. Each such update could make a private repository public, turn off Issues and unarchive an archived repository. From GitHub 0.11.0 these three fields are dropdowns with **Yes**, **No** and **Leave unchanged**. A field the agent leaves out, or sets to Leave unchanged, is not sent, so the repository keeps its current setting.++#### What you need to do++Nothing to configure. Agents read the new options themselves, and a Run Agent tool that already sets one of these fields to true or false keeps sending that value. If an agent ran this action on an earlier GitHub version, check that your private repositories are still private, that Issues are on where you expect them, and that archived repositories are still archived. Run Agent steps keep running on the version they were built with until you upgrade them.+#### Shopify 0.11.0: Update Customer toggles that are off no longer unverify or unsubscribe the customerUpdate Customer sent **Verified Email**, **Send Email Invite** and **Accepts Marketing** on every run. A fresh step saves an untouched toggle as `false`, so every update marked the customer's email as unverified and unsubscribed them from email marketing, whatever the rest of the step changed. From Shopify 0.11.0 a toggle that is off sends nothing and the customer's current setting is kept; a toggle that is on still verifies the email, sends the invite or subscribes the customer. New Update Customer steps no longer start with Verified Email switched on.diff --git a/packages/pieces/community/github/package.json b/packages/pieces/community/github/package.jsonindex f5907c09d49..b8c3bf41307 100644--- a/packages/pieces/community/github/package.json+++ b/packages/pieces/community/github/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/piece-github",- "version": "0.10.1",+ "version": "0.11.0","main": "./dist/src/index.js","types": "./dist/src/index.d.ts","scripts": {diff --git a/packages/pieces/community/github/src/i18n/translation.json b/packages/pieces/community/github/src/i18n/translation.jsonindex c6500cd2bc8..4cdd7dd4496 100644--- a/packages/pieces/community/github/src/i18n/translation.json+++ b/packages/pieces/community/github/src/i18n/translation.json@@ -382,7 +382,12 @@"Initialize with an empty README so the repo has a default branch.": "Initialize with an empty README so the repo has a default branch.","The organization login that will own the repository.": "The organization login that will own the repository.","Resolve via List Branches.": "Resolve via List Branches.",- "Set true to archive the repository (read-only state).": "Set true to archive the repository (read-only state).",+ "Yes makes the repository private, No makes it public. Leave empty or pick Leave unchanged to keep the current setting.": "Yes makes the repository private, No makes it public. Leave empty or pick Leave unchanged to keep the current setting.",+ "Yes turns Issues on, No turns them off. Leave empty or pick Leave unchanged to keep the current setting.": "Yes turns Issues on, No turns them off. Leave empty or pick Leave unchanged to keep the current setting.",+ "Yes archives the repository (read-only state), No unarchives it. Leave empty or pick Leave unchanged to keep the current setting.": "Yes archives the repository (read-only state), No unarchives it. Leave empty or pick Leave unchanged to keep the current setting.",+ "Yes": "Yes",+ "No": "No",+ "Leave unchanged": "Leave unchanged","The branch name. Resolve via List Branches.": "The branch name. Resolve via List Branches.","Branch name or commit SHA to start listing from.": "Branch name or commit SHA to start listing from.","Only commits touching this file path.": "Only commits touching this file path.",diff --git a/packages/pieces/community/github/src/lib/actions/ai/common.ts b/packages/pieces/community/github/src/lib/actions/ai/common.tsindex 4dd761e5009..55ebaf712c1 100644--- a/packages/pieces/community/github/src/lib/actions/ai/common.ts+++ b/packages/pieces/community/github/src/lib/actions/ai/common.ts@@ -19,6 +19,34 @@ export const repoProp = Property.ShortText({required: true,});+export function triStateProp({+ displayName,+ description,+}: {+ displayName: string;+ description: string;+}) {+ return Property.StaticDropdown<string, false>({+ displayName,+ description: `${description} Leave empty or pick Leave unchanged to keep the current setting.`,+ required: false,+ options: {+ disabled: false,+ options: [+ { label: 'Yes', value: 'yes' },+ { label: 'No', value: 'no' },+ { label: 'Leave unchanged', value: 'unchanged' },+ ],+ },+ });+}++export function triStateValue(value: unknown): boolean | undefined {+ if (value === true || value === 'yes') return true;+ if (value === false || value === 'no') return false;+ return undefined;+}+/*** Maps a github httpClient error to a friendly message. Returns the thrown Error.* `resource` is a human label for the 404 (e.g. "Repository owner/repo").diff --git a/packages/pieces/community/github/src/lib/actions/ai/update-repository.ts b/packages/pieces/community/github/src/lib/actions/ai/update-repository.tsindex 291b78673b4..98541e52704 100644--- a/packages/pieces/community/github/src/lib/actions/ai/update-repository.ts+++ b/packages/pieces/community/github/src/lib/actions/ai/update-repository.ts@@ -2,7 +2,13 @@ import { createAction, Property } from '@activepieces/pieces-framework';import { githubAuth } from '../../auth';import { githubApiCall } from '../../common';import { HttpMethod } from '@activepieces/pieces-common';-import { ownerProp, repoProp, githubError } from './common';+import {+ ownerProp,+ repoProp,+ githubError,+ triStateProp,+ triStateValue,+} from './common';import { repositoryBodyOutputSchema } from '../../output-schemas';export const githubUpdateRepositoryAction = createAction({@@ -14,7 +20,7 @@ export const githubUpdateRepositoryAction = createAction({audience: 'ai',aiMetadata: {description:- 'Updates a repository (PATCH /repos/{owner}/{repo}), setting only the fields you provide — name, description, private, default_branch, has_issues, or archived. Idempotent: applying the same values again leaves the repo in the same state. Archiving is reversible only via the GitHub UI/API by un-setting archived.',+ 'Updates a repository (PATCH /repos/{owner}/{repo}), setting only the fields you provide — name, description, private, default_branch, has_issues, or archived. private, has_issues and archived take yes, no or unchanged; leave them out or pass unchanged to keep the current visibility, Issues setting and archive state. Idempotent: applying the same values again leaves the repo in the same state. Archiving is reversible by setting archived to no.',idempotent: true,},props: {@@ -28,39 +34,40 @@ export const githubUpdateRepositoryAction = createAction({displayName: 'Description',required: false,}),- private: Property.Checkbox({+ private: triStateProp({displayName: 'Private',- required: false,+ description: 'Yes makes the repository private, No makes it public.',}),default_branch: Property.ShortText({displayName: 'Default Branch',description: 'Resolve via List Branches.',required: false,}),- has_issues: Property.Checkbox({+ has_issues: triStateProp({displayName: 'Has Issues',- required: false,+ description: 'Yes turns Issues on, No turns them off.',}),- archived: Property.Checkbox({+ archived: triStateProp({displayName: 'Archived',- description: 'Set true to archive the repository (read-only state).',- required: false,+ description:+ 'Yes archives the repository (read-only state), No unarchives it.',}),},outputSchema: repositoryBodyOutputSchema,async run({ auth, propsValue }) {const { owner, repo } = propsValue;+ const isPrivate = triStateValue(propsValue.private);+ const hasIssues = triStateValue(propsValue.has_issues);+ const archived = triStateValue(propsValue.archived);const body: Record<string, unknown> = {};if (propsValue.name !== undefined) body['name'] = propsValue.name;if (propsValue.description !== undefined)body['description'] = propsValue.description;- if (propsValue.private !== undefined) body['private'] = propsValue.private;+ if (isPrivate !== undefined) body['private'] = isPrivate;if (propsValue.default_branch !== undefined)body['default_branch'] = propsValue.default_branch;- if (propsValue.has_issues !== undefined)- body['has_issues'] = propsValue.has_issues;- if (propsValue.archived !== undefined)- body['archived'] = propsValue.archived;+ if (hasIssues !== undefined) body['has_issues'] = hasIssues;+ if (archived !== undefined) body['archived'] = archived;try {const response = await githubApiCall({auth,diff --git a/packages/pieces/community/github/test/update-repository.test.ts b/packages/pieces/community/github/test/update-repository.test.tsnew file mode 100644index 00000000000..4046cbc17d6--- /dev/null+++ b/packages/pieces/community/github/test/update-repository.test.ts@@ -0,0 +1,88 @@+import { afterEach, describe, expect, test, vi } from 'vitest';+import {+ AppConnectionType,+ createMockActionContext,+ InputPropertyMap,+ PropertyType,+} from '@activepieces/pieces-framework';+import { githubUpdateRepositoryAction } from '../src/lib/actions/ai/update-repository';+import { githubApiCall } from '../src/lib/common';+import { GithubAuthValue } from '../src/lib/common/auth-helpers';++vi.mock('../src/lib/common', async (importOriginal) => {+ const original = await importOriginal<typeof import('../src/lib/common')>();+ return { ...original, githubApiCall: vi.fn() };+});++const apiCall = vi.mocked(githubApiCall);++const auth: GithubAuthValue = {+ type: AppConnectionType.SECRET_TEXT,+ secret_text: 'ghp_test',+};++function runUpdate(propsValue: Record<string, unknown>) {+ apiCall.mockResolvedValueOnce({ status: 200, headers: {}, body: {} });+ const fullPropsValue = { owner: 'octo', repo: 'repo', ...propsValue };+ return githubUpdateRepositoryAction.run({+ ...createMockActionContext<InputPropertyMap>({ propsValue: fullPropsValue }),+ auth,+ propsValue: fullPropsValue,+ });+}++function sentBody() {+ return apiCall.mock.calls[0][0].body;+}++describe('githubUpdateRepositoryAction', () => {+ afterEach(() => {+ apiCall.mockReset();+ });++ test('has no optional Checkbox, which the agent path would fill with false', () => {+ const optionalCheckboxes = Object.entries(githubUpdateRepositoryAction.props)+ .filter(([, prop]) => prop.type === PropertyType.CHECKBOX && !prop.required)+ .map(([name]) => name);++ expect(optionalCheckboxes).toEqual([]);+ });++ test('a description-only update leaves visibility, Issues and archive state out of the request', async () => {+ await runUpdate({ description: 'New description' });++ expect(apiCall.mock.calls[0][0].resourceUri).toBe('/repos/octo/repo');+ expect(sentBody()).toEqual({ description: 'New description' });+ });++ test('Leave unchanged sends nothing for that field', async () => {+ await runUpdate({+ description: 'New description',+ private: 'unchanged',+ has_issues: 'unchanged',+ archived: 'unchanged',+ });++ expect(sentBody()).toEqual({ description: 'New description' });+ });++ test('Yes and No send true and false', async () => {+ await runUpdate({ private: 'yes', has_issues: 'no', archived: 'no' });++ expect(sentBody()).toEqual({+ private: true,+ has_issues: false,+ archived: false,+ });+ });++ test('booleans saved by older versions still map to true and false', async () => {+ await runUpdate({ private: true, has_issues: false, archived: true });++ expect(sentBody()).toEqual({+ private: true,+ has_issues: false,+ archived: true,+ });+ });+});