Skip to content

Add Extract feature support - #3

Merged
rafalzawadzki merged 1 commit into
masterfrom
rafalzawadzki/add-extract-feature
Feb 23, 2026
Merged

rafalzawadzki merged 1 commit into
masterfrom
rafalzawadzki/add-extract-feature

Conversation

@rafalzawadzki

Copy link
Copy Markdown

Summary

Added support for the new extract feature from the upgraded Supadata API. This enables AI-powered structured data extraction from video content.

  • New Extract resource with extractData operation
  • Async job-based API polling (5s interval, 5min timeout by default)
  • Two input modes: natural language prompts or JSON Schema definitions
  • Configurable polling behavior via Options field

Test plan

  • Verify the Extract resource appears in the node selector
  • Test with a prompt-only input
  • Test with a schema-only input
  • Test with both prompt and schema
  • Verify polling completes successfully for completed jobs
  • Verify timeout handling for long-running extractions

🤖 Generated with Claude Code

Adds a new Extract resource with extractData operation that submits async jobs
to the Supadata API and polls for results. Supports both natural language prompts
and JSON Schema inputs with configurable polling intervals and timeouts.

Also bump version to 0.4.0 for the new feature.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@rafalzawadzki
rafalzawadzki merged commit 073d9bf into master Feb 23, 2026
1 check passed
@claude

claude Bot commented Feb 23, 2026 •

Copy link
Copy Markdown

Claude finished @rafalzawadzki's task —— View job


PR Review: Add Extract feature support

This is a comprehensive review of the merged PR that adds AI-powered structured data extraction capabilities to the n8n-nodes-supadata package.

✅ Code Quality & Best Practices

Strong Points:

  • Clean separation of concerns: New polling logic properly extracted to GenericFunctions.ts
  • Consistent error handling: Uses NodeApiError consistently throughout
  • Type safety: Proper TypeScript types and interfaces used
  • Parameter validation: Required fields properly marked and validated
  • Backward compatibility: Existing functionality preserved

Minor Improvements:

  • Consider extracting magic numbers (5s, 300s) to constants with meaningful names
  • The nested conditional at lines 539-547 in Supadata.node.ts could benefit from early returns

🐛 Potential Issues

Medium Priority:

  1. Schema parsing vulnerability (Supadata.node.ts:544-546):

    body.schema = typeof schemaValue === 'string'
      ? JSON.parse(schemaValue)  // No error handling
      : schemaValue;

    Risk: Malformed JSON will crash the node
    Fix: Wrap in try-catch with proper error message

  2. Missing null checks (GenericFunctions.ts:102):

    const errorMessage = response.error?.message || 'Extract job failed';

    Risk: If response.error is undefined but truthy, accessing .message could throw
    Fix: Use optional chaining: response.error?.message

⚡ Performance Considerations

Good Practices:

  • ✅ Configurable polling intervals (2-30s range)
  • ✅ Reasonable timeout limits (30-600s)
  • ✅ Efficient polling with setTimeout instead of busy waiting

Recommendations:

  • Consider exponential backoff for polling to reduce API load
  • The 5-minute default timeout might be too aggressive for large video files

🔒 Security Assessment

Well Implemented:

  • ✅ Proper authentication handling via n8n's credential system
  • ✅ Input validation for polling parameters (min/max values)
  • ✅ No hardcoded secrets or credentials

Areas of Concern:

  1. URL validation missing: No validation of extractUrl parameter - could accept malicious URLs
  2. JSON injection: Unprotected JSON.parse() on user input (mentioned above)

🧪 Test Coverage

Missing Test Coverage:

  • ❌ No unit tests for the new supadataApiPollExtractJob function
  • ❌ No integration tests for Extract operations
  • ❌ No error handling tests (timeouts, failed jobs, malformed responses)
  • ❌ No JSON schema parsing edge case tests

Recommendations:

  • Add tests for polling timeout scenarios
  • Test malformed API responses
  • Verify error message propagation
  • Test schema validation edge cases

🏗️ Architecture Review

Excellent Design Decisions:

  • ✅ Async job pattern fits n8n's execution model well
  • ✅ Options collection provides good UX flexibility
  • ✅ Clean resource/operation structure maintains consistency

Suggestions:

  • Consider adding a cancel operation for long-running extract jobs
  • The polling function could return more granular status information

📊 Specific Code Issues

  1. Line 544-546: JSON parsing needs error handling
  2. Line 102: Use optional chaining for safer error access
  3. Line 88-89: Consider extracting constants:
    const DEFAULT_POLL_INTERVAL_SECONDS = 5;
    const DEFAULT_MAX_WAIT_SECONDS = 300;

🎯 Overall Assessment

This is a well-structured addition that follows n8n's patterns and maintains good code quality. The extract feature implementation is solid, but needs attention to error handling and test coverage before production use.

Priority Actions:

  1. 🔴 High: Fix JSON.parse error handling
  2. 🟡 Medium: Add comprehensive test suite
  3. 🟡 Medium: Add URL validation for security
  4. 🟢 Low: Extract magic numbers to constants

Rating: 7.5/10 - Good implementation with some important fixes needed.


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