Skip to content

fix: application basic information is not displayed - #7940

Merged
peslyn merged 1 commit into
v3from
pr@v3@fix_application_basic_information_is_not_displayed
Nov 16, 2026
Merged

peslyn merged 1 commit into
v3from
pr@v3@fix_application_basic_information_is_not_displayed

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: application basic information is not displayed

const query=application.value?.work_flow?.nodes?.find(n=>n.id==='base-node')?.properties?.api_input_field_list?.map((f:any)=>{
return `${f.variable}=${f.default_value}`
}).join('&')
if(query){

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The change is a good defensive fix, but it is only partially robust.

What the patch improves

Adding ?. before .map(...) prevents a crash when api_input_field_list is null or undefined.

Because optional chaining short-circuits the rest of the chain, this expression:

api_input_field_list?.map(...).join('&')

will return undefined instead of throwing when api_input_field_list is nullish.

Potential issues

  1. Non-array values still crash
    If api_input_field_list is a non-nullish non-array value, e.g. an object, then ?.map does not protect you because map is not a function:

    api_input_field_list?.map(...) // TypeError if map is undefined

    Use Array.isArray(...) or ensure the API type guarantees an array.

  2. No URL encoding
    Variables and default values are inserted directly:

    `${f.variable}=${f.default_value}`

    If either contains &, =, spaces, #, etc., the query string can break. Use URLSearchParams or encodeURIComponent.

  3. Implicit string conversion
    If default_value is an object, array, null, or undefined, template literals produce values like [object Object], "null", or "undefined". Decide the expected serialization explicitly.

  4. any type
    f: any hides type errors. Prefer a proper type for API input fields.

  5. Minor: find callback assumes every node is non-null
    If nodes can contain nullish entries, n.id can throw. Use n?.id === 'base-node' if necessary.

  6. Computed result type
    The computed value can be undefined when the field list is missing. If it is later interpolated into a URL, ensure a fallback such as ?? ''.

Suggested safer implementation

const query = computed(() => {
  const fields = application.value?.work_flow?.nodes
    ?.find(n => n?.id === 'base-node')
    ?.properties?.api_input_field_list

  if (!Array.isArray(fields)) return ''

  const params = new URLSearchParams()

  fields.forEach((f: any) => {
    if (f?.variable == null) return
    params.append(f.variable, String(f.default_value ?? ''))
  })

  return params.toString()
})

This version:

  • Safely handles missing fields
  • Guarantees a string result
  • Properly URL-encodes values
  • Avoids .map(...).join(...) on a possibly non-array value

Verdict

The diff fixes the obvious nullish crash, but for production code I would still add array validation and URL encoding.

@peslyn
peslyn merged commit 416856c into v3 Nov 16, 2026
3 of 4 checks passed
@peslyn
peslyn deleted the pr@v3@fix_application_basic_information_is_not_displayed branch November 16, 2026 08:38
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.

2 participants