Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Strings } from "../constants";
import { Constants, Strings } from "../constants";
import { askCopilotQuestionAsync } from "../services/backendRequests";
import { logDebug, logError } from "../services/loggingService";
import { ErrorCode } from "../types/errorCode";
Expand All @@ -7,14 +7,26 @@ export async function runAiQuestionValidationPlanAsync(
plan: pxt.blocks.ValidatorPlan
): Promise<pxt.blocks.EvaluationResult | undefined> {
// Expect single aiQuestion check and nothing else.
if (plan.checks.length !== 1 && plan.checks[0].validator !== "aiQuestion") {
if (plan.checks.length !== 1 || plan.checks[0].validator !== "aiQuestion") {
logError(ErrorCode.invalidValidatorPlan, { planName: plan.name, checks: plan.checks });
return undefined;
}

const inputs = plan.checks[0] as pxt.blocks.AiQuestionValidatorCheck;
logDebug(`Asking question: '${inputs.question}' on project with shareId: '${inputs.shareId}'`);
const response = await askCopilotQuestionAsync(inputs.shareId, inputs.question);
const trimmedQuestion = (inputs.question || "").trim();

if (trimmedQuestion.length < Constants.MinAIQuestionLength) {
logDebug(`Skipping AI validation: question below min length (${trimmedQuestion.length}/${Constants.MinAIQuestionLength}).`);
return {
executionSuccess: false,
result: undefined,
notes: undefined,
executionErrorMsg: Strings.QuestionTooShort,
};
}

logDebug(`Asking question: '${trimmedQuestion}' on project with shareId: '${inputs.shareId}'`);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this something that we're allowed to log? Could it possibly have PII?

Copy link
Copy Markdown
Member Author

@jwunderl jwunderl Feb 3, 2026

Choose a reason for hiding this comment

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

logdebug is console.log / only local

const response = await askCopilotQuestionAsync(inputs.shareId, trimmedQuestion);
logDebug(`Response: ${response}`);

return {
Expand Down
Loading