Skip to content

Conversation

@fllppi
Copy link

@fllppi fllppi commented Nov 15, 2025

What kind of change does this PR introduce?

This PR adds the ability to upload files from URLs to Postiz, like it's documented in the API documentation.
https://docs.postiz.com/public-api#upload-a-new-file-from-an-existing-url

Why was this change needed?

Currently, the only way to upload files to Postiz in n8n is by using a custom http request node.

Other information:

Summary by CodeRabbit

  • New Features

    • Added "Upload File from URL" to Postiz — upload files directly from web URLs with a required URL field and client-side URL format and protocol validation.
  • Bug Fixes

    • Corrected action label capitalization for existing Postiz actions ("Schedule a post to Postiz" and "Upload a file to Postiz").

@coderabbitai
Copy link

coderabbitai bot commented Nov 15, 2025

Walkthrough

A new "Upload File From URL" operation (uploadFileFromURL) was added to the Postiz node. It introduces a required url parameter, validates the URL is HTTP/HTTPS, and sends a POST to /upload-from-url with payload { url }. Existing operations remain unchanged.

Changes

Cohort / File(s) Summary
Postiz node updates
nodes/Postiz/Postiz.node.ts
Added "Upload File From URL" operation (uploadFileFromURL), added required url string parameter (shown only for that operation), URL format and protocol validation (http/https), and execution branch that POSTs { url } to /upload-from-url. Existing operations retained.

Sequence Diagram

sequenceDiagram
    participant User
    participant PostizNode as "Postiz Node"
    participant Validator as "URL Validator"
    participant PostizAPI as "Postiz API"

    User->>PostizNode: execute operation=uploadFileFromURL with url
    PostizNode->>Validator: validate URL format & protocol (http/https)
    alt valid URL
        PostizNode->>PostizAPI: POST /upload-from-url { url }
        PostizAPI-->>PostizNode: 2xx response
        PostizNode-->>User: return success
    else invalid URL
        Validator-->>PostizNode: invalid
        PostizNode-->>User: throw NodeOperationError
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Check URL validation edge cases (leading/trailing whitespace, empty strings).
  • Verify error type/message uses NodeOperationError and matches project patterns.
  • Confirm endpoint path /upload-from-url and payload { url } match API contract.

Poem

🐰 I sniffed a link beneath the moon,
A hop, a check — is it http or https? soon!
If tidy and true, I send it on its way,
A little POST, then I dance and play. 🎉

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: adding upload file from URL functionality to the Postiz node, which matches the core purpose of the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8fd5dde and 9901d8e.

📒 Files selected for processing (1)
  • nodes/Postiz/Postiz.node.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • nodes/Postiz/Postiz.node.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
nodes/Postiz/Postiz.node.ts (1)

766-777: Consider more robust URL validation.

The current validation only checks for the http:// or https:// prefix, which allows malformed URLs like "http://" or "https://incomplete" to pass. Using the URL constructor provides better validation.

Apply this diff for more comprehensive validation:

 			if (operation === 'uploadFileFromURL') {
 				const url = this.getNodeParameter('url', i) as string;
-				// Check if it's a valid URL
-				if (!url.startsWith('http://') && !url.startsWith('https://')) {
+				
+				// Validate URL format
+				try {
+					const parsedUrl = new URL(url);
+					if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
+						throw new Error('Invalid protocol');
+					}
+				} catch {
 					throw new NodeOperationError(
 						this.getNode(),
-						`URL is not a valid URL: ${url}`,
+						`Invalid URL format. URL must be a valid http:// or https:// address`,
 						{ itemIndex: i },
 					);
 				}
+				
 				responseData = await postizApiRequest.call(this, 'POST', '/upload-from-url', { url });
 			}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 152f5b6 and dfbc36c.

📒 Files selected for processing (1)
  • nodes/Postiz/Postiz.node.ts (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
nodes/Postiz/Postiz.node.ts (1)
nodes/Postiz/GenericFunctions.ts (1)
  • postizApiRequest (13-42)
🪛 ESLint
nodes/Postiz/Postiz.node.ts

[error] 77-77: Change to title case [autofixable]

(n8n-nodes-base/node-param-display-name-miscased)

🔇 Additional comments (2)
nodes/Postiz/Postiz.node.ts (2)

600-613: LGTM!

The URL parameter is properly configured with appropriate display conditions, type, and description.


776-776: Code matches Postiz API specification.

The endpoint path /upload-from-url, HTTP method POST, and payload structure { url } all match the official Postiz API documentation. No changes required.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
nodes/Postiz/Postiz.node.ts (1)

76-81: Address the linting errors for display name and action casing.

The ESLint linter is flagging casing issues that were also noted in previous review comments:

  • Line 77: Display name should be in title case: 'Upload File From URL' (capitalize "From")
  • Line 80: Action should follow sentence case convention per n8n guidelines

Apply this diff to fix the casing:

 {
-	name: 'Upload File from URL',
+	name: 'Upload File From URL',
 	value: 'uploadFileFromURL',
 	description: 'Upload a file to Postiz from URL',
-	action: 'Upload a file to Postiz from URL',
+	action: 'Upload a file to Postiz from url',
 },
🧹 Nitpick comments (1)
nodes/Postiz/Postiz.node.ts (1)

766-777: Consider more robust URL validation.

The current validation only checks if the URL starts with http:// or https://, which prevents obvious errors but allows malformed URLs through (e.g., http:// with nothing after).

Consider using the URL constructor for more comprehensive validation:

 if (operation === 'uploadFileFromURL') {
 	const url = this.getNodeParameter('url', i) as string;
-	// Check if it's a valid URL
-	if (!url.startsWith('http://') && !url.startsWith('https://')) {
+	// Validate URL format
+	try {
+		const parsedUrl = new URL(url);
+		if (parsedUrl.protocol !== 'http:' && parsedUrl.protocol !== 'https:') {
+			throw new Error('Invalid protocol');
+		}
+	} catch {
 		throw new NodeOperationError(
 			this.getNode(),
-			`URL is not a valid URL: ${url}`,
+			`Invalid URL format: ${url}. Please provide a valid HTTP or HTTPS URL.`,
 			{ itemIndex: i },
 		);
 	}
 	responseData = await postizApiRequest.call(this, 'POST', '/upload-from-url', { url });
 }

This approach catches malformed URLs and provides clearer error messages.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dfbc36c and 6518167.

📒 Files selected for processing (1)
  • nodes/Postiz/Postiz.node.ts (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
nodes/Postiz/Postiz.node.ts (1)
nodes/Postiz/GenericFunctions.ts (1)
  • postizApiRequest (13-42)
🪛 ESLint
nodes/Postiz/Postiz.node.ts

[error] 44-44: Change to sentence case [autofixable]

(n8n-nodes-base/node-param-operation-option-action-miscased)


[error] 74-74: Change to sentence case [autofixable]

(n8n-nodes-base/node-param-operation-option-action-miscased)


[error] 77-77: Change to title case [autofixable]

(n8n-nodes-base/node-param-display-name-miscased)


[error] 80-80: Change to sentence case [autofixable]

(n8n-nodes-base/node-param-operation-option-action-miscased)

🔇 Additional comments (2)
nodes/Postiz/Postiz.node.ts (2)

44-44: Good fix for brand consistency.

Correctly capitalizing "Postiz" in the action strings improves consistency across the node.

Also applies to: 74-74


600-613: Well-structured parameter definition.

The URL parameter is properly configured with appropriate visibility controls and clear description.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
nodes/Postiz/Postiz.node.ts (1)

76-81: Fix casing issues in operation definition.

These issues were previously flagged but remain unresolved. ESLint confirms:

  • Line 77 name should use title case: "Upload File From URL" (capitalize "From")
  • Line 80 action should use sentence case: "Upload a file to postiz from URL" (lowercase "postiz")

Apply this diff:

 				{
-					name: 'Upload File from URL',
+					name: 'Upload File From URL',
 					value: 'uploadFileFromURL',
 					description: 'Upload a file to Postiz from URL',
-					action: 'Upload a file to Postiz from URL',
+					action: 'Upload a file to postiz from URL',
 				},

As per coding guidelines (ESLint: n8n-nodes-base/node-param-display-name-miscased, n8n-nodes-base/node-param-operation-option-action-miscased)

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6518167 and 8fd5dde.

📒 Files selected for processing (1)
  • nodes/Postiz/Postiz.node.ts (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
nodes/Postiz/Postiz.node.ts (1)
nodes/Postiz/GenericFunctions.ts (1)
  • postizApiRequest (13-42)
🪛 ESLint
nodes/Postiz/Postiz.node.ts

[error] 44-44: Change to sentence case [autofixable]

(n8n-nodes-base/node-param-operation-option-action-miscased)


[error] 74-74: Change to sentence case [autofixable]

(n8n-nodes-base/node-param-operation-option-action-miscased)


[error] 77-77: Change to title case [autofixable]

(n8n-nodes-base/node-param-display-name-miscased)


[error] 80-80: Change to sentence case [autofixable]

(n8n-nodes-base/node-param-operation-option-action-miscased)


[error] 772-772: Use ApplicationError, NodeApiError, NodeOperationError, or TriggerCloseError` [non-autofixable]

(n8n-nodes-base/node-execute-block-wrong-error-thrown)

🔇 Additional comments (1)
nodes/Postiz/Postiz.node.ts (1)

600-613: LGTM!

The URL parameter is properly defined with appropriate display conditions, required validation, and clear description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant