kaxil opened a new pull request, #74702:
URL: https://github.com/apache/airflow/pull/74702

   A HITL param declared `type="string"` whose value looks like a JSON object 
shows `[object Object]` in the review form, and the form sends it back as an 
object. An untouched Approve then fails the task:
   
   ```
   ParamValidationError: Invalid input for param payload: {'id': 
12345678901234567000, 'name': 'widget'} is not of type 'string'
   ```
   
   The reviewer can't edit the field either, and the value goes through JS 
number parsing on the way, so integers above 2\*\*53 are rounded 
(`12345678901234567890` came back as `12345678901234567000` above). The 
common.ai `LLMOperator(require_approval=True, allow_modifications=True, 
output_type=<model>)` hits this on every structured output, since it defers 
with the model's JSON dump as a string `output` param.
   
   `getHITLParamsDict` JSON-parses any string value that starts with `{`. The 
parse was added in #58611 for values preloaded from URL query params, which 
always arrive as strings. Since #68397 the value comes from `params_input` or 
the param's own default instead, so the parse now also applies to string 
defaults. The declared schema is spread over the inferred one afterwards, so 
the field keeps `type: "string"`, `FieldString` renders the object, and 
`getHITLFormData` submits it.
   
   The fix only parses when the declared schema allows an object: no declared 
type, `"object"`, or a type list that includes `"object"` and not `"string"`. A 
string or nullable-string param keeps its text. #58611's case is unaffected: an 
object value still renders as an object, and a JSON string under an object or 
untyped schema still parses. Tests cover both, plus a big-int string 
round-tripping unchanged. The string-param tests fail without the change.
   
   Verified in a browser against a Dag with a plain `HITLOperator` (string 
param, JSON default) and an `LLMOperator` using pydantic-ai's `TestModel`. With 
the fix, `hitlDetails` returns `params_input` values as strings for both 
untouched and edited approvals, and the downstream tasks receive them (the 
`LLMOperator` downstream gets the edited `Ticket` model).
   
   Before:
   
   ![HITL form before](./hitl-before.png)
   
   After:
   
   ![HITL form after](./hitl-after.png)
   
   #74473 works around this in common.ai by accepting a dict for a string 
param. That workaround can go once a core release carries this fix.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to