- 
                Notifications
    
You must be signed in to change notification settings  - Fork 2.9k
 
Extractor variable support #5727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Extractor variable support #5727
Conversation
| 
           Thanks so much for your contribution @murat-kekij !  | 
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a panic in unit test due to nil pointer dereference
| 
           This pull request has been automatically marked as stale due to inactivity. It will be closed in 7 days if no further activity occurs. Please update if you wish to keep it open.  | 
    
          
WalkthroughThe changes introduce support for variable resolution in regex and JSON extractors. Extractor methods now accept a data map for dynamic variable evaluation. Compilation and extraction logic are updated to check for unresolved variables, evaluate them at runtime using the data context, and compile the resulting patterns or queries as needed. Method signatures and internal extractor calls are updated accordingly. Changes
 Sequence Diagram(s)sequenceDiagram
    participant Caller
    participant Extractor
    participant Expressions
    Caller->>Extractor: ExtractRegex(corpus, data)
    loop For each regex pattern
        Extractor->>Expressions: ContainsUnresolvedVariables(pattern)
        alt Unresolved variables found
            Extractor->>Expressions: Evaluate(pattern, data)
            Extractor->>Extractor: Compile evaluated pattern
            alt Compilation fails
                Extractor->>Extractor: Log warning, skip
            end
        else No unresolved variables
            Extractor->>Extractor: Use precompiled pattern
        end
        Extractor->>Extractor: Extract matches
    end
    Extractor-->>Caller: Return unique matches
    sequenceDiagram
    participant Caller
    participant Extractor
    participant Expressions
    Caller->>Extractor: ExtractJSON(corpus, data)
    loop For each JSON query
        Extractor->>Expressions: ContainsUnresolvedVariables(query)
        alt Unresolved variables found
            Extractor->>Expressions: Evaluate(query, data)
            Extractor->>Extractor: Compile evaluated query
            alt Compilation fails
                Extractor->>Extractor: Log warning, skip
            end
        else No unresolved variables
            Extractor->>Extractor: Use precompiled query
        end
        Extractor->>Extractor: Extract results
    end
    Extractor-->>Caller: Return unique results
    Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (10)
 🧰 Additional context used🧠 Learnings (3)pkg/protocols/http/operators.go (1)Learnt from: dwisiswant0 pkg/protocols/file/operators.go (1)Learnt from: dwisiswant0 pkg/operators/extractors/compile.go (2)Learnt from: hdm Learnt from: hdm 🔇 Additional comments (16)
 ✨ Finishing Touches
 🧪 Generate unit tests
 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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit: 
 SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
 Other keywords and placeholders
 CodeRabbit Configuration File (
 | 
    
Proposed changes
Closes #2647
Test Server
Test Json Extractor
Test Regex Extractor
Command
Checklist
Summary by CodeRabbit
New Features
Bug Fixes
Tests