Share prepared pipeline source validation
This commit is contained in:
@@ -13,7 +13,6 @@ import (
|
||||
func prepareRunSource(ctx context.Context, input *RunInput) (*source.SourceDocument, error) {
|
||||
debugRecorder := input.Debug
|
||||
adapter := input.Prepared.input
|
||||
var doc *source.SourceDocument
|
||||
sourceStarted := time.Now().UTC()
|
||||
if debugRecorder.Enabled() {
|
||||
if err := writeDebugTimed(debugRecorder, "source/input.json", debugTimedEnvelope{
|
||||
@@ -30,25 +29,12 @@ func prepareRunSource(ctx context.Context, input *RunInput) (*source.SourceDocum
|
||||
return nil, fmt.Errorf("write source debug artifact: %w", err)
|
||||
}
|
||||
}
|
||||
requestMetadata, err := cloneMetadata(input.Metadata)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("clone input adapter metadata: %w", err)
|
||||
}
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
doc, err = adapter.Parse(ctx, contracts.ParseRequest{
|
||||
doc, err := input.Prepared.ParseSource(ctx, contracts.ParseRequest{
|
||||
SourceID: input.SourceID, Path: input.Path, Raw: input.RawInput,
|
||||
LLMProfile: input.pipeline.Input.LLMProfile, Metadata: requestMetadata,
|
||||
Metadata: input.Metadata,
|
||||
})
|
||||
if ctxErr := ctx.Err(); ctxErr != nil {
|
||||
return nil, ctxErr
|
||||
}
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parse input with adapter %q: %w", adapter.Key(), err)
|
||||
}
|
||||
if err := source.ValidateDocument(doc); err != nil {
|
||||
return nil, fmt.Errorf("validate source document: %w", err)
|
||||
return nil, err
|
||||
}
|
||||
index := source.NewDocumentIndex(doc)
|
||||
input.sourceIndex = &index
|
||||
|
||||
Reference in New Issue
Block a user