dify icon indicating copy to clipboard operation
dify copied to clipboard

http节点,报错422. 变量如果是直接写没事,如果引用变量就422

Open xiaoyaoaiqima opened this issue 9 months ago • 17 comments

Self Checks

  • [x] This is only for bug report, if you would like to ask a question, please head to Discussions.
  • [x] I have searched for existing issues search for existing issues, including closed ones.
  • [x] I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • [x] Please do not modify this template :) and fill in all the required fields.

Dify version

1.0

Cloud or Self Hosted

Self Hosted (Source)

Steps to reproduce

[

Image

Image

](url)

✔️ Expected Behavior

No response

❌ Actual Behavior

No response

xiaoyaoaiqima avatar Mar 28 '25 12:03 xiaoyaoaiqima

@justinmk Thanks for noticing my contribution here :-) May I ask, what does the "needs:response" label stand for? I couldn't find a question (this PR, referred issue, etc.) but I wonder if it may have potential further meaning? Thx in advance.

juditnovak avatar Mar 04 '25 16:03 juditnovak

@justinmk Thanks very much for the review.

I had a question while working on this code. Isn't it an "overkill" to add the amount of (sensitive) changes to fix an --after all-- small issue? In case your judgement is to rather have this change, I'm more than happy to polish it to perfect :-) (I'm actively working on tracking down the issue of the windows pipeline.)

juditnovak avatar Mar 10 '25 18:03 juditnovak

Isn't it an "overkill" to add the amount of (sensitive) changes to fix an --after all-- small issue?

I wouldn't say https://github.com/neovim/neovim/issues/32550 is a small issue. It's pointing to a bug I had worried about, and could affect other libraries loaded by nvim.

envmap was never really a good solution, and I'm glad you are finally getting rid of it :) It's true that this work is delicate and will require careful review, but we don't really have an alternative.

I think memfree can be avoided in some of these cases. Also, if there are many cases that only want to quickly check the result of os_getenv, we could add os_getenv_noalloc which writes to NameBuff (and returns a pointer to it), to save the caller the trouble of freeing the result.

justinmk avatar Mar 10 '25 22:03 justinmk

@justinmk Thank you very much for additional suggestions and most importantly the confirmation of the value of this work. I'm very glad it's useful :-)
Also thanks for the foreseen particularly careful review -- keeps me re-assured :-)

I carry on accordingly, evaluating cases for a potential os_getenv_noalloc. Thx very much :-)

juditnovak avatar Mar 11 '25 08:03 juditnovak

Simple changes are applied, pipelines are :green_circle: :tada:

Making an attempt for os_getenv_noalloc in an upcoming commit.

juditnovak avatar Mar 11 '25 17:03 juditnovak

@zeertzjq Thanks for your response. os_env_exists uses cool trick :-) But I'm a bit confused, how to benefit from a similar approach here. Would you suggest to use uv_os_getenv() to retrieve the value to NameBuff directly? (I apologize if I'm overlooking something obvious...)

juditnovak avatar Mar 12 '25 09:03 juditnovak

No, I mean there are some cases where the caller only needs to check if an environment variable is empty. In such cases an allocation can be avoided, as they don't actually need to use the string, and can use a boolean value instead.

zeertzjq avatar Mar 12 '25 09:03 zeertzjq

I see your point, but I can't map that usage to the case in question. The actual value of NVIM_APPNAME seems to be used in all cases (potentially slightly transformed).

Case 1: Direct return value

const char *appname = get_appname(false)

Case 2: Using the (slightly transformed) value loaded to NameBuff (src/nvim/os/stdpaths.c)

(void *)get_appname(true);   // Loading NVIM_APPNAME to NameBuff
int r = snprintf(..., name ? name : NameBuff, ...)

I'm not sure how an existence check may come useful :-( (Pls let me know if I'm on a wrong track.)

juditnovak avatar Mar 12 '25 10:03 juditnovak

I was talking about vim_mktempdir() etc.

zeertzjq avatar Mar 12 '25 10:03 zeertzjq

@zeertzjq Thanks for the clarification, now your message is clear. (The context was confusing, I thought the suggestion was targeting this issue.)

The existence check only appears on a few occasions, yet I agree that an os_env_defined() (similar to os_env_exists()) could increase clarity and avoid memory allocation. I'm adding it with in the next round. Thanks.

juditnovak avatar Mar 12 '25 10:03 juditnovak

In order to keep individually fully functional stages separate, I've left this PR as a fully "polished" version of os_getenv() usage on each occasion.

I'm introducting the code with os_env_defined() (suggested by @zeertzjq ) and os_getenv_noalloc() (suggested by @justinmk ) in PR II., demonstrating the transition the code discussed here. (Of course, to be added here at the end, and merged to master as a single change.)

juditnovak avatar Mar 14 '25 16:03 juditnovak

Added changes from PR II., including fixes for comments:

  • @zeertzjq:
  • https://github.com/juditnovak/neovim/pull/1#discussion_r1996402380
  • https://github.com/juditnovak/neovim/pull/1#discussion_r1996402865
  • @justinmk:
  • https://github.com/juditnovak/neovim/pull/1#discussion_r1996825716

juditnovak avatar Mar 17 '25 00:03 juditnovak

NOTE: All commits will be squashed into the first commit (that has the correct, linted structure) once the review process is over. Until then lintcommit pipeline errors could be ignored.

juditnovak avatar Mar 26 '25 11:03 juditnovak

Requests completed + added a few more simplifications and tests.

juditnovak avatar Apr 01 '25 19:04 juditnovak

(Once final, I'd squash all commits into the 1st one, that already has the correct commit message format, so it would be prepared for merge to master.)

juditnovak avatar Apr 01 '25 19:04 juditnovak

Could you pls suggest if the test failure I see after the latest rebase is a known flaky behaviour of the tests? I tried to reproduce both locally and on GH pipelines. Thanks.

juditnovak avatar Apr 02 '25 14:04 juditnovak

Yes

zeertzjq avatar Apr 02 '25 14:04 zeertzjq

Re-base to latest master (no code changes).

juditnovak avatar Apr 07 '25 09:04 juditnovak

@justinmk @zeertzjq Are there any outstanding actions on my side? Please let me know in case I may be missing something... (No pressure in case it's for you to take action. I just wanted to double-check if I may be blocking progress :-) )

juditnovak avatar Apr 08 '25 20:04 juditnovak

Maybe we should also have a test for vim.uv.os_unsetenv (the repro steps from https://github.com/neovim/neovim/issues/32550 ) in test/functional/ (not test/unit/)? May need a new test/functional/core/env_spec.lua file.

justinmk avatar Apr 14 '25 14:04 justinmk

@justinmk Functional test added as requested (with reference to the original issue). Pls check.

Once all approved, I'm squashing the new commits into 1st one (and of course do a rebase at that point as well :-) )

juditnovak avatar Apr 15 '25 16:04 juditnovak

Once all approved, I'm squashing the new commits into 1st one (and of course do a rebase at that point as well :-) )

no need since you merged master here. we can squash at merge-time.

thanks!

justinmk avatar Apr 15 '25 16:04 justinmk

Functional test added as requested

was it pushed? don't see it

justinmk avatar Apr 15 '25 16:04 justinmk

@justinmk I apologize :facepalm:

Added now in the corresponding, last commit. (Previous content of this commit, i.e. variable rename on a unittest was added to the rest of the requested fixes.)

juditnovak avatar Apr 15 '25 16:04 juditnovak

:tada:

:-) :-) :-)

juditnovak avatar Apr 16 '25 10:04 juditnovak