Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/violet-jobs-doubt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@redocly/cli": patch
---

Fixed an issue where the `mount-path` option was not validated, leading to errors when used with an empty path or a path identical to the project path.
2 changes: 1 addition & 1 deletion docs/@v1/commands/push.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ REDOCLY_AUTHORIZATION=<api-key> redocly push <files> --organization <organizatio
| files | [string] | **REQUIRED.** List of folders and/or files to upload. |
| --organization, -o | string | **REQUIRED.** Organization slug. |
| --project, -p | string | **REQUIRED.** Project slug. |
| --mount-path, -mp | string | **REQUIRED.** The path where the files are mounted in the project. |
| --mount-path, -mp | string | **REQUIRED.** The path where the files are mounted in the project. Cannot be empty or identical to the project path. |
Comment thread
mark-redocly marked this conversation as resolved.
| --branch, -b | string | **REQUIRED.** The branch files are pushed from. |
| --author, -a | string | **REQUIRED.** The author of the push in the format: `'Author Name <author-email@example.com>'`. |
| --message, -m | string | **REQUIRED.** The commit message for the push. |
Expand Down
2 changes: 1 addition & 1 deletion docs/@v2/commands/push.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ REDOCLY_AUTHORIZATION=<api-key> redocly push <files> --organization <organizatio
| files | [string] | **REQUIRED.** List of folders and/or files to upload. |
| --organization, -o | string | **REQUIRED.** Organization slug. |
| --project, -p | string | **REQUIRED.** Project slug. |
| --mount-path, -mp | string | **REQUIRED.** The path where the files are mounted in the project. |
| --mount-path, -mp | string | **REQUIRED.** The path where the files are mounted in the project. Cannot be empty or identical to the project path. |
| --branch, -b | string | **REQUIRED.** The branch files are pushed from. |
| --author, -a | string | **REQUIRED.** The author of the push in the format: `'Author Name <author-email@example.com>'`. |
| --message, -m | string | **REQUIRED.** The commit message for the push. |
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
import { handleRespect, type RespectArgv } from './commands/respect/index.js';
import { version } from './utils/package.js';
import { validatePositiveNumber } from './utils/validate-positive-number.js';
import { validateMountPath } from './utils/validate-mount-path.js';
import { validateMtlsCommandOption } from './commands/respect/mtls/validate-mtls-command-option.js';

import type { Arguments } from 'yargs';
Expand Down Expand Up @@ -247,6 +248,7 @@ yargs(hideBin(process.argv))
type: 'string',
alias: 'mp',
required: true,
coerce: validateMountPath,
},
author: {
description: 'Author of the commit.',
Expand Down
22 changes: 22 additions & 0 deletions packages/cli/src/utils/__tests__/validate-mount-path.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { describe, it, expect } from 'vitest';
import { validateMountPath } from '../validate-mount-path.js';

describe('validateMountPath', () => {
it('should accept valid mount path', () => {
expect(validateMountPath('/docs')).toBe('/docs');
expect(validateMountPath('/api/v1')).toBe('/api/v1');
expect(validateMountPath('/my-path')).toBe('/my-path');
});

it('should reject empty mount path', () => {
expect(() => validateMountPath('')).toThrow(
Comment thread
mark-redocly marked this conversation as resolved.
'Mount path cannot be empty or root path. Please use --mount-path option with a valid path.'
);
});

it('should reject root path "/"', () => {
expect(() => validateMountPath('/')).toThrow(
'Mount path cannot be empty or root path. Please use --mount-path option with a valid path.'
);
});
});
8 changes: 8 additions & 0 deletions packages/cli/src/utils/validate-mount-path.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export function validateMountPath(value: string) {
if (!value || value === '/') {
throw new Error(
'Mount path cannot be empty or root path. Please use --mount-path option with a valid path.'
);
}
return value;
}
Loading