Skip to content

[Components] Fix function columns by composing wire object set#2955

Closed
ziyunp wants to merge 5 commits intomainfrom
zpoh/fix-func
Closed

[Components] Fix function columns by composing wire object set#2955
ziyunp wants to merge 5 commits intomainfrom
zpoh/fix-func

Conversation

@ziyunp
Copy link
Copy Markdown
Contributor

@ziyunp ziyunp commented Apr 7, 2026

Fixing regression on function columns after useObjectSet and useOsdkObjects is fixed to return the rich object set only when loading is false. The function query expects wire object set and not the rich object set.

Error:
Screenshot 2026-04-07 at 13 53 46

Expected param:

{
  "employees": {
    "type": "filter",
    "objectSet": {
      "type": "filter",
      "objectSet": {
        "type": "base",
        "objectType": "Employee"
      },
      "where": {
        "type": "eq",
        "field": "employeeNumber",
        "value": 657495071
      }
    },
  }
}

@ziyunp ziyunp changed the title Return wireObjectSet Return wireObjectSet in useOsdkObjects and useObjectSet Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

size-limit report 📦

Path Size Change
@osdk/api 432 B 0%
@osdk/client 24.11 kB 0%
@osdk/oauth 6.52 kB 0%
@osdk/react 513 B 0%
@osdk/react/experimental 50.08 kB +2.31% 🔺
@osdk/react/experimental/admin 2.43 kB 0%
@osdk/react-components 10 B 0%
@osdk/react-components/experimental 320.01 kB +0.55% 🔺
@osdk/react-components/primitives 40.33 kB 0%
@osdk/widget.client-react 10.56 kB 0%

const baseResult = shouldUseObjectSet ? objectSetResult : osdkObjectsResult;

// Omitting withProperties as it causes an error when present in the function param
const wireObjectSet = useMemo(() => {
Copy link
Copy Markdown
Contributor Author

@ziyunp ziyunp Apr 7, 2026

Choose a reason for hiding this comment

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

@KuberSethi An option is to compose the wireObjectSet here and remove the wireObjectSet from the hooks return values.

I will need to do this anyway because the function query fails when there are derived properties in the object set param.

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.

because the function query fails when there are derived properties in the object set param.

Why is this failing / could you share more details?

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.

I believe it's a function api issue. I raised this with the functions team

Copy link
Copy Markdown
Contributor

@KuberSethi KuberSethi left a comment

Choose a reason for hiding this comment

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

initial comments - lots of minor things (typing can be tightened in a lot of places) but I want to index on directionality first. I think it's possible to do this internally without changing our contracts but let me know if you disagree.

took an initial (very LLM driven) approach to illustrate, again ignore any specific errors lets just lock down directionality rn #2957

// eslint-disable-next-line react-hooks/exhaustive-deps
const stableObjectSet = useMemo(() => objectSet, [JSON.stringify(objectSet)]);
const stableObjectSet = useMemo(() => wireObjectSet, [
// eslint-disable-next-line react-hooks/exhaustive-deps
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.

Here and above why do we have this eslint disable? Maybe I'm missing something but there's nothing about this usecase that would require this imo, surely we can get rid of it and rearchitect things to where its not necessary?

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.

It's just a nit where I suppress the warning for the wireObjectSet dependency that I intentionally leave out to return a stable object set based on their stringified value.

const baseResult = shouldUseObjectSet ? objectSetResult : osdkObjectsResult;

// Omitting withProperties as it causes an error when present in the function param
const wireObjectSet = useMemo(() => {
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.

because the function query fails when there are derived properties in the object set param.

Why is this failing / could you share more details?

* Composes a base ObjectSet with hook options and returns the wire
* representation. Available immediately — does not depend on loading state.
*/
export function composeWireObjectSet(
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.

I think this is identical to ObjectSetQuery.composeObjectSet()? Any chance of reuse or nah?

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.

We we will need to make #composeObjectSet a static function and use it here. I can do that if you have no problem making it a static method of ObjectSetQuery class

Copy link
Copy Markdown
Contributor Author

@ziyunp ziyunp Apr 7, 2026

Choose a reason for hiding this comment

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

Hmm.. ObjectSetQuery is in @osdk/client and to do this we will need to export ObjectSetQuery from client. I'd prefer to duplicate the logic than to export that class in @osdk/client. What do u think?

* The wire representation of the final ObjectSet after all transformations.
* Available immediately without waiting for loading to complete.
*/
wireObjectSet: ReturnType<typeof getWireObjectSet> | undefined;
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.

hmm I think this is really confusing to users, especially to LLMs, do we need to expose this or is there a way to make this internal?

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.

Yeah so I was considering to only export composeWireObjectSet function, and compose it within the useObjectTableData hook

@ziyunp ziyunp changed the title Return wireObjectSet in useOsdkObjects and useObjectSet Fix function columns by composing wire object set Apr 7, 2026
@ziyunp ziyunp changed the title Fix function columns by composing wire object set [Components] Fix function columns by composing wire object set Apr 8, 2026
queryDefinition: config.queryDefinition,
options: {
params: config.getParams(stableObjectSet),
params: config.getParams(composedObjectSet!),
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.

can we drop ! by dropping the intermediate stableObjectSet?

* limitations under the License.
*/

export { composeObjectSet } from "../new/composeObjectSet.js";
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.

should we export this?

*
* This is a copy of ObjectSetQuery.#composeObjectSet in @osdk/client
*/
export function composeObjectSet<
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.

suggestion (not-blocking): could we add a TODO to reuse the one from @osdk/client?

RDPs
>;
}
if (options.where) {
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.

question (blocking): how are we using the filter passed through the objectsTableApi?

let result: ObjectSet<Q, RDPs> = baseObjectSet;

if (options.withProperties) {
result = result.withProperties(options.withProperties) as ObjectSet<
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.

I may be missing something but I thought we wanted to drop this?

@ziyunp
Copy link
Copy Markdown
Contributor Author

ziyunp commented Apr 8, 2026

Closing this PR with fixes in the new PR: #2967

@ziyunp ziyunp closed this Apr 8, 2026
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.

3 participants